laravel resource response from different data code example
Example 1: use resource in laravel 8
php artisan make:controller PhotoController --resource --model=Photo
Example 2: laravel resource set status code
use App\User;
use App\Http\Resources\User as UserResource;
Route::get('/user', function () {
return (new UserResource(User::find(1)))
->response()
->setStatusCode(200);
});