ajout de filtre de guides et informations
This commit is contained in:
@@ -8,13 +8,23 @@ use Illuminate\Http\Request;
|
|||||||
|
|
||||||
class InformationController extends Controller
|
class InformationController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$informations = Information::where('is_published', true)
|
$query = Information::where('is_published', true);
|
||||||
->orderBy('created_at', 'desc')
|
|
||||||
->paginate(6);
|
|
||||||
|
|
||||||
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)
|
public function show($id)
|
||||||
|
|||||||
@@ -10,11 +10,21 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
|
|
||||||
class RelaxationController extends Controller
|
class RelaxationController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$activities = RelaxationActivity::all();
|
$query = RelaxationActivity::query();
|
||||||
$favorites = [];
|
|
||||||
return view('relaxation.index', compact('activities', 'favorites'));
|
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)
|
public function toggleFavorite($id)
|
||||||
|
|||||||
@@ -2,9 +2,24 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="container mx-auto px-4 py-8">
|
<div class="container mx-auto px-4 py-8">
|
||||||
<div class="mb-8">
|
<div class="mb-8 flex flex-col md:flex-row md:items-end md:justify-between gap-4">
|
||||||
<h1 class="text-3xl font-bold text-indigo-900">Informations & Santé Mentale</h1>
|
<div>
|
||||||
<p class="text-gray-600">Découvrez nos conseils et articles pour mieux gérer votre quotidien.</p>
|
<h1 class="text-3xl font-bold text-indigo-900">Informations & Santé Mentale</h1>
|
||||||
|
<p class="text-gray-600">Découvrez nos conseils et articles pour mieux gérer votre quotidien.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-wrap gap-2">
|
||||||
|
<a href="{{ route('informations.index') }}"
|
||||||
|
class="px-4 py-2 rounded-full text-sm font-medium transition-colors {{ !request('category') ? 'bg-indigo-600 text-white' : 'bg-gray-100 text-gray-600 hover:bg-gray-200' }}">
|
||||||
|
Toutes
|
||||||
|
</a>
|
||||||
|
@foreach($categories as $category)
|
||||||
|
<a href="{{ route('informations.index', ['category' => $category]) }}"
|
||||||
|
class="px-4 py-2 rounded-full text-sm font-medium transition-colors {{ request('category') == $category ? 'bg-indigo-600 text-white' : 'bg-gray-100 text-gray-600 hover:bg-gray-200' }}">
|
||||||
|
{{ $category }}
|
||||||
|
</a>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
||||||
|
|||||||
@@ -74,9 +74,24 @@
|
|||||||
|
|
||||||
<!-- Section Activités -->
|
<!-- Section Activités -->
|
||||||
<div class="space-y-8">
|
<div class="space-y-8">
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
||||||
<h2 class="text-xl font-bold text-slate-900 uppercase tracking-widest whitespace-nowrap">Bibliothèque Méditation</h2>
|
<div class="flex items-center gap-4 flex-1">
|
||||||
<div class="h-1 flex-1 bg-slate-100"></div>
|
<h2 class="text-xl font-bold text-slate-900 uppercase tracking-widest whitespace-nowrap">Bibliothèque Méditation</h2>
|
||||||
|
<div class="h-1 flex-1 bg-slate-100"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-wrap gap-2">
|
||||||
|
<a href="{{ route('relaxation.index') }}"
|
||||||
|
class="px-4 py-2 rounded-full text-[10px] font-bold uppercase transition-all {{ !request('category') ? 'bg-[--fr-blue] text-white shadow-md' : 'bg-slate-100 text-slate-600 hover:bg-slate-200' }}">
|
||||||
|
Toutes
|
||||||
|
</a>
|
||||||
|
@foreach($categories as $category)
|
||||||
|
<a href="{{ route('relaxation.index', ['category' => $category]) }}"
|
||||||
|
class="px-4 py-2 rounded-full text-[10px] font-bold uppercase transition-all {{ request('category') == $category ? 'bg-[--fr-blue] text-white shadow-md' : 'bg-slate-100 text-slate-600 hover:bg-slate-200' }}">
|
||||||
|
{{ $category }}
|
||||||
|
</a>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
||||||
|
|||||||
Reference in New Issue
Block a user