Amended owned by search filter to use slugs
This commit is contained in:
parent
c8564b7792
commit
71ccb90ef4
2 changed files with 5 additions and 7 deletions
|
@ -289,13 +289,11 @@ class SearchRunner
|
||||||
|
|
||||||
protected function filterOwnedBy(EloquentBuilder $query, Entity $model, $input)
|
protected function filterOwnedBy(EloquentBuilder $query, Entity $model, $input)
|
||||||
{
|
{
|
||||||
if (!is_numeric($input) && $input !== 'me') {
|
$userSlug = $input === 'me' ? user()->slug : trim($input);
|
||||||
return;
|
$user = User::query()->where('slug', '=', $userSlug)->first(['id']);
|
||||||
|
if ($user) {
|
||||||
|
$query->where('owned_by', '=', $user->id);
|
||||||
}
|
}
|
||||||
if ($input === 'me') {
|
|
||||||
$input = user()->id;
|
|
||||||
}
|
|
||||||
$query->where('owned_by', '=', $input);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function filterInName(EloquentBuilder $query, Entity $model, $input)
|
protected function filterInName(EloquentBuilder $query, Entity $model, $input)
|
||||||
|
|
|
@ -135,7 +135,7 @@ class EntitySearchTest extends TestCase
|
||||||
$this->get('/search?term=' . urlencode('danzorbhsing {created_by:me}'))->assertDontSee($page->name);
|
$this->get('/search?term=' . urlencode('danzorbhsing {created_by:me}'))->assertDontSee($page->name);
|
||||||
$this->get('/search?term=' . urlencode('danzorbhsing {updated_by:me}'))->assertDontSee($page->name);
|
$this->get('/search?term=' . urlencode('danzorbhsing {updated_by:me}'))->assertDontSee($page->name);
|
||||||
$this->get('/search?term=' . urlencode('danzorbhsing {owned_by:me}'))->assertDontSee($page->name);
|
$this->get('/search?term=' . urlencode('danzorbhsing {owned_by:me}'))->assertDontSee($page->name);
|
||||||
$this->get('/search?term=' . urlencode('danzorbhsing {updated_by:'.$editorId.'}'))->assertDontSee($page->name);
|
$this->get('/search?term=' . urlencode('danzorbhsing {updated_by:'.$editorSlug.'}'))->assertDontSee($page->name);
|
||||||
$page->created_by = $editorId;
|
$page->created_by = $editorId;
|
||||||
$page->save();
|
$page->save();
|
||||||
$this->get('/search?term=' . urlencode('danzorbhsing {created_by:me}'))->assertSee($page->name);
|
$this->get('/search?term=' . urlencode('danzorbhsing {created_by:me}'))->assertSee($page->name);
|
||||||
|
|
Loading…
Reference in a new issue