If you want to create route grouping based on your sub-domain, This post will help you to make your routing how to make grouping based on a sub-domain. This is very to understand this and setup in your route file.
If you wish to make your routing group based on a sub-domain for the make panel and front site separate. like the main domain for the front website and the admin panel for the sub-domain, so you do it very simply by referring to this post.
How to group routes based on sub-domain?
Route::domain('{sub_domain}.example.com')->group(function () { Route::get('user/{id}', function ($sub_domain, $id) { // YOUR CONTROLLER LOGIC GOES HERE }); });
Prefix Url
You can call a method prefix, using the prefix route method you can apply any prefix URL path to the app that grouping routes.
Route::prefix('admin')->group(function () { Route::get('user',[HomeController::class,index]); });
Prefix Route
In case, if you want to give a prefix route name for the specific route groups, you can call the name route method in the route grouping.
Route::name('admin.')->group(function () { Route::get('user',[HomeController::class,index])->name('dashboard'); });
Call Middleware
If you want to call specific middleware to the route grouping using the middleware method you can use it, This method also accepts the array, so you can check more then one middleware.
Route::middleware(['auth.check'])->group(function () { Route::get('user',[HomeController::class,index])->name('dashboard'); });
Create Custom Route File With New Service Provider Laravel 8 9
Laravel Routing Multiple Method Use In Single Route
Route Resource Controller Laravel
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- Laravel 6 - Preview and Crop Image Before Upload using Ajax
- Laravel 10 Handle Image Upload Example Tutorial
- Laravel 10 Create Custom Helper Function Example
- Email Send Using Queue In Laravel
- could not encode content to iso-8859-1
- Error : The MAC is invalid Question's And Solutions [Solved]
- How To Generate A Sitemap In Laravel 6/7/8/9
- File name required when file upload laravel validation rules
- Laravel Delete Image From Storage Folder
- Laravel Country State City Dropdown Using AJAX