From da929d5edcb45f7fad433c8522fc88e32b59520f Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Wed, 10 Mar 2021 22:51:18 +0000 Subject: [PATCH] Updates search to use user slugs --- app/Entities/Tools/SearchRunner.php | 21 +++++++++------------ app/Http/Controllers/SearchController.php | 3 --- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/app/Entities/Tools/SearchRunner.php b/app/Entities/Tools/SearchRunner.php index acfe8d956..dc2c04e3e 100644 --- a/app/Entities/Tools/SearchRunner.php +++ b/app/Entities/Tools/SearchRunner.php @@ -1,6 +1,7 @@ slug : trim($input); + $user = User::query()->where('slug', '=', $userSlug)->first(['id']); + if ($user) { + $query->where('created_by', '=', $user->id); } - if ($input === 'me') { - $input = user()->id; - } - $query->where('created_by', '=', $input); } protected function filterUpdatedBy(EloquentBuilder $query, Entity $model, $input) { - if (!is_numeric($input) && $input !== 'me') { - return; + $userSlug = $input === 'me' ? user()->slug : trim($input); + $user = User::query()->where('slug', '=', $userSlug)->first(['id']); + if ($user) { + $query->where('updated_by', '=', $user->id); } - if ($input === 'me') { - $input = user()->id; - } - $query->where('updated_by', '=', $input); } protected function filterInName(EloquentBuilder $query, Entity $model, $input) diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 21ebea378..bb824fd9b 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -1,9 +1,6 @@