diff --git a/app/Filters/ClientFilters.php b/app/Filters/ClientFilters.php index 5fae1e910955..19642f1c259b 100644 --- a/app/Filters/ClientFilters.php +++ b/app/Filters/ClientFilters.php @@ -18,6 +18,7 @@ use Illuminate\Database\Eloquent\Builder; */ class ClientFilters extends QueryFilters { + /** * Filter by name. * diff --git a/app/Filters/QueryFilters.php b/app/Filters/QueryFilters.php index 818af708a52c..e207a8052264 100644 --- a/app/Filters/QueryFilters.php +++ b/app/Filters/QueryFilters.php @@ -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]) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index d0f17d0a170c..7faeaf96b82d 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -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()