laravel make resource code example
Example 1: laravel create resource controller
php artisan make:controller PhotoController --resource
Example 2: laravel create resource controller
php artisan make:controller PhotoController --resource --model=Photo
Example 3: 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);
});
Example 4: Laravel 8 Resource
php artisan make:controller BlogController --resource
Example 5: resource controller laravel
Route::resource('photos', PhotoController::class);
Example 6: how to create resource controller in laravel
Resource Controller:This controller will create all CRUD methods
php artisan make:controller nameOfController --resource