xxxxxxxxxx
php artisan make:controller PhotoController --resource --model=Photo
Route::resource('photos', PhotoController::class);
Resource:
Resource is like class which is used to convert the database models into JSON serializable data which will be sent from the server form the API
xxxxxxxxxx
php artisan make:resource UserResource
xxxxxxxxxx
use App\Http\Controllers\PhotoController;
Route::resource('photos', PhotoController::class);
Verb URI Action Route Name
GET /photos index photos.index
GET /photos/create create photos.create
POST /photos store photos.store
GET /photos/{photo} show photos.show
GET /photos/{photo}/edit edit photos.edit
PUT/PATCH /photos/{photo} update photos.update
DELETE /photos/{photo} destroy photos.destroy
xxxxxxxxxx
Resource Controller:This controller will create all CRUD methods
php artisan make:controller nameOfController --resource