e3da625927
- Backend Laravel 11 (API REST, JWT auth, PostgreSQL) - Frontend Next.js 14 (React, TypeScript, Tailwind CSS) - Docker Compose (PostgreSQL, backend, frontend) - Modules : auth, profil, tracker émotions, informations, admin
27 lines
640 B
PHP
27 lines
640 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Feed;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class FeedController extends Controller
|
|
{
|
|
public function index(): JsonResponse
|
|
{
|
|
$feeds = Feed::publie()
|
|
->orderBy('ordre')
|
|
->orderBy('created_at', 'desc')
|
|
->get(['id', 'titre', 'slug', 'contenu', 'image_url', 'ordre', 'created_at']);
|
|
|
|
return response()->json($feeds);
|
|
}
|
|
|
|
public function show(string $slug): JsonResponse
|
|
{
|
|
$feed = Feed::publie()->where('slug', $slug)->with('auteur:id,nom,prenom')->firstOrFail();
|
|
|
|
return response()->json($feed);
|
|
}
|
|
}
|