Laravel 9 route group with controller
Laravel 9 route group with controller
In this session, we are going to try to solve the "Laravel 9 route group with controller" puzzle by using the computer language.
You can group all the routes which utilize the same controller using controller method in Laravel 9.-
Route grouping with controller
--PATH routes\web.phpuse App\Http\Controllers\OrderController; Route::controller(OrderController::class)->group(function () { Route::get('/orders/{id}', 'show'); Route::post('/orders', 'store'); });
If a group of routes uses the same controller then you can group all the routes using the controller method.
Additional Note:
1. Create OrderController using php artisan command - php artisan make:controller OrderController
2. Import/use controller in routes/web.php using use App\Http\Controllers\OrderController;
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- How to call model in blade laravel
- Insert values in pivot table dynamically in laravel
- How to pass query string with pagination in laravel
- How to add dynamic page title in Laravel view
- Call to undefined method App\Models\User::follow()
- How to add foreign key in laravel using migration
- Laravel get all records with pagination
- Get domain name in laravel
- How to implement toggleLike() method in Overtrue\LaravelLike laravel package
- Declaration of App\Models\Post::sluggable() must be compatible with Cviebrock\EloquentSluggable\Sluggable
- How to remove package from laravel
- There are no commands defined in the "route:" namespace
- How to create pivot table in laravel using migration
- How to pass query string to url in laravel
- Ajax POST request in laravel
- Link storage folder in laravel 8
- Syntax error or access violation: 1072 Key column 'role_id' doesn't exist in table (SQL: alter table `users` add constraint `users_role_id_foreign` foreign key (`role_id`) references `roles` (`id`))
- How to create laravel project using jetstream
- Send OTP using textlocal api in laravel
- Route group with URI prefix using middleware and route name prefixes
- JQuery each loop on json response after ajax in laravel
- Get latest record by created at in Laravel
- How to get specific columns using Laravel eloquent methods
- Extra Filter Query on Relationships in Laravel
- Connection could not be established with host smtp.gmail.com :stream_socket_client(): unable to connect to tcp://smtp.gmail.com:587 (Connection refused)"