ajout de filtre de guides et informations
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -10,11 +10,21 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RelaxationController extends Controller
|
||||
{
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
$activities = RelaxationActivity::all();
|
||||
$favorites = [];
|
||||
return view('relaxation.index', compact('activities', 'favorites'));
|
||||
$query = RelaxationActivity::query();
|
||||
|
||||
if ($request->has('category') && $request->category != '') {
|
||||
$query->where('category', $request->category);
|
||||
}
|
||||
|
||||
$activities = $query->get();
|
||||
|
||||
$categories = RelaxationActivity::distinct()->pluck('category');
|
||||
|
||||
$favorites = []; // TODO: Implémenter la logique des favoris si nécessaire
|
||||
|
||||
return view('relaxation.index', compact('activities', 'favorites', 'categories'));
|
||||
}
|
||||
|
||||
public function toggleFavorite($id)
|
||||
|
||||
Reference in New Issue
Block a user