From: Dan Brown Date: Wed, 10 Mar 2021 22:51:18 +0000 (+0000) Subject: Updates search to use user slugs X-Git-Tag: v21.04~1^2~11^2~21^2~1 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/da929d5edcb45f7fad433c8522fc88e32b59520f Updates search to use user slugs --- 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 @@ id; + $userSlug = $input === 'me' ? user()->slug : trim($input); + $user = User::query()->where('slug', '=', $userSlug)->first(['id']); + if ($user) { + $query->where('created_by', '=', $user->id); } - $query->where('created_by', '=', $input); } protected function filterUpdatedBy(EloquentBuilder $query, Entity $model, $input) { - if (!is_numeric($input) && $input !== 'me') { - return; - } - if ($input === 'me') { - $input = user()->id; + $userSlug = $input === 'me' ? user()->slug : trim($input); + $user = User::query()->where('slug', '=', $userSlug)->first(['id']); + if ($user) { + $query->where('updated_by', '=', $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 @@