Skip to content

Commit

Permalink
Filters
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebacker committed Oct 30, 2018
1 parent 1c9734e commit fabab20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Http/Controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace TypiCMS\Modules\Partners\Http\Controllers;

use Illuminate\Http\Request;
use Spatie\QueryBuilder\Filter;
use Spatie\QueryBuilder\QueryBuilder;
use TypiCMS\Modules\Core\Filters\FilterOr;
use TypiCMS\Modules\Core\Http\Controllers\BaseApiController;
use TypiCMS\Modules\Partners\Models\Partner;
use TypiCMS\Modules\Partners\Repositories\EloquentPartner;
Expand All @@ -18,7 +20,10 @@ public function __construct(EloquentPartner $partner)
public function index(Request $request)
{
$data = QueryBuilder::for(Partner::class)
->with('image')
->allowedFilters([
Filter::custom('title', FilterOr::class),
])
->allowedIncludes('image')
->translated($request->input('translatable_fields'))
->paginate($request->input('per_page'));

Expand Down
3 changes: 2 additions & 1 deletion src/resources/views/admin/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
translatable-fields="status,title"
table="partners"
title="partners"
:searchable="['id']"
include="image"
:searchable="['title']"
:sorting="['position']">

<template slot="add-button">
Expand Down

0 comments on commit fabab20

Please sign in to comment.