mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-26 02:10:19 +08:00
Updates search to use user slugs
This commit is contained in:
parent
124c4d0778
commit
da929d5edc
|
@ -1,6 +1,7 @@
|
||||||
<?php namespace BookStack\Entities\Tools;
|
<?php namespace BookStack\Entities\Tools;
|
||||||
|
|
||||||
use BookStack\Auth\Permissions\PermissionService;
|
use BookStack\Auth\Permissions\PermissionService;
|
||||||
|
use BookStack\Auth\User;
|
||||||
use BookStack\Entities\EntityProvider;
|
use BookStack\Entities\EntityProvider;
|
||||||
use BookStack\Entities\Models\Entity;
|
use BookStack\Entities\Models\Entity;
|
||||||
use Illuminate\Database\Connection;
|
use Illuminate\Database\Connection;
|
||||||
|
@ -270,24 +271,20 @@ class SearchRunner
|
||||||
|
|
||||||
protected function filterCreatedBy(EloquentBuilder $query, Entity $model, $input)
|
protected function filterCreatedBy(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('created_by', '=', $user->id);
|
||||||
}
|
}
|
||||||
if ($input === 'me') {
|
|
||||||
$input = user()->id;
|
|
||||||
}
|
|
||||||
$query->where('created_by', '=', $input);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function filterUpdatedBy(EloquentBuilder $query, Entity $model, $input)
|
protected function filterUpdatedBy(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('updated_by', '=', $user->id);
|
||||||
}
|
}
|
||||||
if ($input === 'me') {
|
|
||||||
$input = user()->id;
|
|
||||||
}
|
|
||||||
$query->where('updated_by', '=', $input);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function filterInName(EloquentBuilder $query, Entity $model, $input)
|
protected function filterInName(EloquentBuilder $query, Entity $model, $input)
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
<?php namespace BookStack\Http\Controllers;
|
<?php namespace BookStack\Http\Controllers;
|
||||||
|
|
||||||
use BookStack\Actions\ViewService;
|
use BookStack\Actions\ViewService;
|
||||||
use BookStack\Entities\Models\Book;
|
|
||||||
use BookStack\Entities\Models\Bookshelf;
|
|
||||||
use BookStack\Entities\Models\Entity;
|
|
||||||
use BookStack\Entities\Tools\SearchRunner;
|
use BookStack\Entities\Tools\SearchRunner;
|
||||||
use BookStack\Entities\Tools\ShelfContext;
|
use BookStack\Entities\Tools\ShelfContext;
|
||||||
use BookStack\Entities\Tools\SearchOptions;
|
use BookStack\Entities\Tools\SearchOptions;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user