Utilisez des ressources dans Laravel 8
php artisan make:controller PhotoController --resource --model=Photo
Leonardo Dal Ronco
php artisan make:controller PhotoController --resource --model=Photo
php artisan make:resource ResourceName
use App\User;
use App\Http\Resources\User as UserResource;
Route::get('/user', function () {
return (new UserResource(User::find(1)))
->response()
->setStatusCode(200);
});