Skip to content

Commit

Permalink
QueryBuilder upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebacker committed Sep 4, 2019
1 parent 25fa07b commit 2915aa0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/Http/Controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/resources/views/admin/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
<item-list
url-base="/api/places"
locale="{{ config('typicms.content_locale') }}"
fields="id,image_id,address"
translatable-fields="status,title"
fields="id,image_id,address,status,title"
table="places"
title="places"
include="image"
Expand Down

0 comments on commit 2915aa0

Please sign in to comment.