diff --git a/app/Auth/Permissions/PermissionApplicator.php b/app/Auth/Permissions/PermissionApplicator.php index 9a39f3e90..d840ccd16 100644 --- a/app/Auth/Permissions/PermissionApplicator.php +++ b/app/Auth/Permissions/PermissionApplicator.php @@ -74,9 +74,8 @@ class PermissionApplicator } foreach ($chain as $currentEntity) { - if (is_null($currentEntity->restricted)) { - throw new InvalidArgumentException("Entity restricted field used but has not been loaded"); + throw new InvalidArgumentException('Entity restricted field used but has not been loaded'); } if ($currentEntity->restricted) { diff --git a/app/Auth/User.php b/app/Auth/User.php index 393965e0d..6e66bc808 100644 --- a/app/Auth/User.php +++ b/app/Auth/User.php @@ -249,6 +249,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon } $this->avatarUrl = $avatar; + return $avatar; } diff --git a/app/Console/Commands/RegenerateSearch.php b/app/Console/Commands/RegenerateSearch.php index 20e3fc798..ff584da56 100644 --- a/app/Console/Commands/RegenerateSearch.php +++ b/app/Console/Commands/RegenerateSearch.php @@ -3,7 +3,7 @@ namespace BookStack\Console\Commands; use BookStack\Entities\Models\Entity; -use BookStack\Entities\Tools\SearchIndex; +use BookStack\Search\SearchIndex; use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; diff --git a/app/Entities/Models/Entity.php b/app/Entities/Models/Entity.php index 17f018a56..ffb9b9c7d 100644 --- a/app/Entities/Models/Entity.php +++ b/app/Entities/Models/Entity.php @@ -11,7 +11,6 @@ use BookStack\Auth\Permissions\EntityPermission; use BookStack\Auth\Permissions\JointPermission; use BookStack\Auth\Permissions\JointPermissionBuilder; use BookStack\Auth\Permissions\PermissionApplicator; -use BookStack\Entities\Tools\SearchIndex; use BookStack\Entities\Tools\SlugGenerator; use BookStack\Interfaces\Deletable; use BookStack\Interfaces\Favouritable; @@ -19,6 +18,8 @@ use BookStack\Interfaces\Loggable; use BookStack\Interfaces\Sluggable; use BookStack\Interfaces\Viewable; use BookStack\Model; +use BookStack\Search\SearchIndex; +use BookStack\Search\SearchTerm; use BookStack\Traits\HasCreatorAndUpdater; use BookStack\Traits\HasOwner; use Carbon\Carbon; diff --git a/app/Http/Controllers/Api/SearchApiController.php b/app/Http/Controllers/Api/SearchApiController.php index 5c4112f74..7ef714390 100644 --- a/app/Http/Controllers/Api/SearchApiController.php +++ b/app/Http/Controllers/Api/SearchApiController.php @@ -3,9 +3,9 @@ namespace BookStack\Http\Controllers\Api; use BookStack\Entities\Models\Entity; -use BookStack\Entities\Tools\SearchOptions; -use BookStack\Entities\Tools\SearchResultsFormatter; -use BookStack\Entities\Tools\SearchRunner; +use BookStack\Search\SearchOptions; +use BookStack\Search\SearchResultsFormatter; +use BookStack\Search\SearchRunner; use Illuminate\Http\Request; class SearchApiController extends ApiController diff --git a/app/Http/Controllers/PageRevisionController.php b/app/Http/Controllers/PageRevisionController.php index ea80e13cd..c4d5fbc7b 100644 --- a/app/Http/Controllers/PageRevisionController.php +++ b/app/Http/Controllers/PageRevisionController.php @@ -27,9 +27,9 @@ class PageRevisionController extends Controller { $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug); $revisions = $page->revisions()->select([ - 'id', 'page_id', 'name', 'created_at', 'created_by', 'updated_at', - 'type', 'revision_number', 'summary', - ]) + 'id', 'page_id', 'name', 'created_at', 'created_by', 'updated_at', + 'type', 'revision_number', 'summary', + ]) ->selectRaw("IF(markdown = '', false, true) as is_markdown") ->with(['page.book', 'createdBy']) ->get(); @@ -38,7 +38,7 @@ class PageRevisionController extends Controller return view('pages.revisions', [ 'revisions' => $revisions, - 'page' => $page, + 'page' => $page, ]); } diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 4a002298c..699733e37 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -3,10 +3,10 @@ namespace BookStack\Http\Controllers; use BookStack\Entities\Queries\Popular; -use BookStack\Entities\Tools\SearchOptions; -use BookStack\Entities\Tools\SearchResultsFormatter; -use BookStack\Entities\Tools\SearchRunner; use BookStack\Entities\Tools\SiblingFetcher; +use BookStack\Search\SearchOptions; +use BookStack\Search\SearchResultsFormatter; +use BookStack\Search\SearchRunner; use Illuminate\Http\Request; class SearchController extends Controller diff --git a/app/Entities/Tools/SearchIndex.php b/app/Search/SearchIndex.php similarity index 99% rename from app/Entities/Tools/SearchIndex.php rename to app/Search/SearchIndex.php index db44daadf..8c793a109 100644 --- a/app/Entities/Tools/SearchIndex.php +++ b/app/Search/SearchIndex.php @@ -1,12 +1,11 @@ =', '=', '<', '>', 'like', '!=']; + protected array $queryOperators = ['<=', '>=', '=', '<', '>', 'like', '!=']; /** * Retain a cache of score adjusted terms for specific search options. diff --git a/app/Entities/Models/SearchTerm.php b/app/Search/SearchTerm.php similarity index 91% rename from app/Entities/Models/SearchTerm.php rename to app/Search/SearchTerm.php index 4ec8d6c45..d416b0059 100644 --- a/app/Entities/Models/SearchTerm.php +++ b/app/Search/SearchTerm.php @@ -1,6 +1,6 @@