<?php namespace BookStack\Entities\Tools;
use BookStack\Auth\Permissions\PermissionService;
+use BookStack\Auth\User;
use BookStack\Entities\EntityProvider;
use BookStack\Entities\Models\Entity;
use Illuminate\Database\Connection;
protected function filterCreatedBy(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('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)
<?php namespace BookStack\Http\Controllers;
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\ShelfContext;
use BookStack\Entities\Tools\SearchOptions;