✨ Ajoute les filtres
This commit is contained in:
@@ -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]);
|
||||
|
Reference in New Issue
Block a user