laravel resource in route code example
Example 1: laravel route resources
// Implicit Model Binding Routes can be created with one line using either:
Route::resource('photos', PhotoController::class);
// OR
Route::resources([
'photos' => PhotoController::class,
'posts' => PostController::class,
]);
php artisan make:controller PhotoController --resource --model=Photo
// makes a controller with stubouts for methods:
// index
// create
// store
// show
// edit
// update
// destroy
Example 2: Route::resource('/posts','PostController');
Route::resources([
'photos' => 'PhotoController',
'posts' => 'PostController',
]);
Example 3: laravel create resource controller
php artisan make:controller PhotoController --resource --model=Photo