<?php
namespace AppHttpControllers;
use AppUser;
use IlluminateHttpRequest;
class UserController extends Controller
{
public function index(Request $request)
{
$users = User::where('is_active', true);
if ($request->has('age_more_than')) {
$users->where('age', '>', $request->age_more_than);
}
if ($request->has('gender')) {
$users->where('gender', $request->gender);
}
if ($request->has('created_at')) {
$users->where('created_at','>=', $request->created_at);
}
return $users->get();
}
}
$nbr_heures = array_filter($request->all(), function ($key) {
return strpos($key, 'nbr_heure_') === 0;
}, ARRAY_FILTER_USE_KEY);