ajout de filtre de guides et informations

This commit is contained in:
2026-05-14 19:09:28 +02:00
parent 4633805dbd
commit 89610b807c
4 changed files with 65 additions and 15 deletions
@@ -8,13 +8,23 @@ use Illuminate\Http\Request;
class InformationController extends Controller
{
public function index()
public function index(Request $request)
{
$informations = Information::where('is_published', true)
->orderBy('created_at', 'desc')
->paginate(6);
$query = Information::where('is_published', true);
return view('informations.index', compact('informations'));
if ($request->has('category') && $request->category != '') {
$query->where('category', $request->category);
}
$informations = $query->orderBy('created_at', 'desc')
->paginate(6)
->withQueryString();
$categories = Information::where('is_published', true)
->distinct()
->pluck('category');
return view('informations.index', compact('informations', 'categories'));
}
public function show($id)