diff --git a/src/Http/Controllers/ApiController.php b/src/Http/Controllers/ApiController.php index 1b633ba..e757d6a 100644 --- a/src/Http/Controllers/ApiController.php +++ b/src/Http/Controllers/ApiController.php @@ -6,7 +6,7 @@ use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Pagination\LengthAwarePaginator; -use Spatie\QueryBuilder\Filter; +use Spatie\QueryBuilder\AllowedFilter; use Spatie\QueryBuilder\QueryBuilder; use TypiCMS\Modules\Core\Filters\FilterOr; use TypiCMS\Modules\Core\Http\Controllers\BaseApiController; @@ -18,11 +18,12 @@ class ApiController extends BaseApiController public function index(Request $request): LengthAwarePaginator { $data = QueryBuilder::for(Place::class) + ->selectFields($request->input('fields.places')) + ->allowedSorts(['id', 'status_translated', 'title_translated']) ->allowedFilters([ - Filter::custom('title', FilterOr::class), + AllowedFilter::custom('title', new FilterOr), ]) - ->allowedIncludes('image') - ->translated($request->input('translatable_fields')) + ->allowedIncludes(['image']) ->paginate($request->input('per_page')); return $data; diff --git a/src/resources/views/admin/index.blade.php b/src/resources/views/admin/index.blade.php index 307c263..8d657d3 100644 --- a/src/resources/views/admin/index.blade.php +++ b/src/resources/views/admin/index.blade.php @@ -7,8 +7,7 @@