Ajoute les filtres

This commit is contained in:
2020-07-24 11:06:49 +02:00
parent a8d9309103
commit 7c9d19c8c0
4 changed files with 63 additions and 12 deletions

View File

@@ -18,13 +18,18 @@ class HomeController extends Controller
public function index()
{
$homes = QueryBuilder::for(Home::class)
// ->allowedFilters(['price', 'surface', 'garden_surface'])
->allowedFilters([
AllowedFilter::scope('price_min'),
AllowedFilter::scope('price_max'),
AllowedFilter::scope('surface_min'),
AllowedFilter::scope('surface_max'),
AllowedFilter::scope('garden_surface_min'),
AllowedFilter::scope('garden_surface_max'),
])
->defaultSort('-created_at') // https://docs.spatie.be/laravel-query-builder/v2/features/sorting/#basic-usage
->paginate(4)
->paginate(10)
->appends(request()->query());
return view('homes.home', ['homes' => $homes]);