1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Fixes for ?with query when using hashed_id

This commit is contained in:
David Bomba 2023-04-27 16:36:58 +10:00
parent 9dee71bc92
commit d884537e20
3 changed files with 19 additions and 10 deletions

View File

@ -18,6 +18,7 @@ use Illuminate\Database\Eloquent\Builder;
*/
class ClientFilters extends QueryFilters
{
/**
* Filter by name.
*

View File

@ -293,8 +293,16 @@ abstract class QueryFilters
return $this->builder;
}
public function with(string $value): Builder
public function with(string $value = ''): Builder
{
if (strlen($value) == 0) {
return $this->builder;
}
if($this->with_property == 'id') {
$value = $this->decodePrimaryKey($value);
}
return $this->builder
->orWhere($this->with_property, $value)
->orderByRaw("{$this->with_property} = ? DESC", [$value])

View File

@ -40,15 +40,15 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
// DB::listen(function($query) {
// nlog(
// $query->sql,
// [
// 'bindings' => $query->bindings,
// 'time' => $query->time
// ]
// );
// });
\DB::listen(function($query) {
nlog(
$query->sql,
[
'bindings' => $query->bindings,
'time' => $query->time
]
);
});
// Model::preventLazyLoading(
// !$this->app->isProduction()