I am working on an ecommerce website I have an admin panel as well as seller panel. I have a product module in the admin panel. Actually i want to use the same module in the seller panel also but I want to use the same route for both of the panel. Seller panel is in sub domain and the admin panel is the main domain. I have also provided groups. Is it possible to use the same route with any conditional code without having to use different routes for both admin and seller panels. Please help me out.
Route File
//Seller Panel
Route::group(['domain' => 'seller.techmart.local'], function () {
//Login
Route::any('/', ['uses' => 'Frontend\Seller\Login\LoginController#getLogin', 'as' => 'login']);
Route::any('/sellerlogin', ['uses' => 'Frontend\Seller\Login\LoginController#ProcessLogin', 'as' => 'sellerlogin']);
//Dashboard
Route::any('/seller-dashboard', ['uses' => 'Frontend\Seller\Dashboard\DashboardController#GetIndex', 'as' => 'seller-dashboard']);
});
//Main Domain
Route::group(['domain' => 'techmart.local'], function () {
//Admin Panel
Route::group(['prefix' => 'masterpanel', 'middleware' => 'masterpanel'], function() {
//login
Route::any('/', ['uses' => 'Admin\LoginController#getLogin', 'as' => 'login']);
Route::any('processlogin', ['uses' => 'Admin\LoginController#doLogin', 'as' => 'processlogin']);
Route::any('/logout', ['uses' => 'Admin\LoginController#logout', 'as' => 'logout']);
//dashboard
Route::any('dashboard', ['uses' => 'Admin\DashboardController#getDashboard', 'as' => 'dashboard']);
/********** Category **********/
Route::any('/brand', ['uses' => 'Brand\BrandController#ManageBrand', 'as' => 'brand']);
Route::any('/savebrand', ['uses' => 'Brand\BrandController#SaveBrand', 'as' => 'savebrand']);
Route::any('/viewbrand/{id}', ['uses' => 'Brand\BrandController#ViewBrand', 'as' => 'viewbrand']);
Route::any('/editbrand/{id}', ['uses' => 'Brand\BrandController#EditBrand', 'as' => 'editbrand']);
Route::any('/updatebrand', ['uses' => 'Brand\BrandController#UpdateBrand', 'as' => 'updatebrand']);
Route::any('/deletebrand', ['uses' => 'Brand\BrandController#DeleteBrand', 'as' => 'deletebrand']);
Route::any('/importbrand', ['uses' => 'Brand\BrandController#ImportBrand', 'as' => 'importbrand']);
Route::any('/deleteselectedbrand', ['uses' => 'Brand\BrandController#DeleteSelectedBrand', 'as' => 'deleteselectedbrand']);
Route::any('/deleteallbrand', ['uses' => 'Brand\BrandController#DeleteAllBrand', 'as' => 'deleteallbrand']);
/********** Product Type **********/
Route::any('/addproducttype', ['uses' => 'ProductType\ProductTypeController#AddProductType', 'as' => 'addproducttype']);
Route::any('/saveproducttype', ['uses' => 'ProductType\ProductTypeController#SaveProductType', 'as' => 'saveproducttype']);
Route::any('/manageproducttype', ['uses' => 'ProductType\ProductTypeController#ManageProductType', 'as' => 'manageproducttype']);
Route::any('/editproducttype/{id}', ['uses' => 'ProductType\ProductTypeController#EditProductType', 'as' => 'editproducttype']);
Route::any('/updateproducttype', ['uses' => 'ProductType\ProductTypeController#UpdateProductType', 'as' => 'updateproducttype']);
Route::any('/deleteproducttype', ['uses' => 'ProductType\ProductTypeController#DeleteProductType', 'as' => 'deleteproducttype']);
Route::any('/deleteselectedproducttype', ['uses' => 'ProductType\ProductTypeController#DeleteSelectedRecords', 'as' => 'deleteselectedproducttype']);
/********** Category **********/
//Category
Route::any('/category', ['uses' => 'Category\CategoryController#ManageCategory', 'as' => 'category']);
Route::any('/savecategory', ['uses' => 'Category\CategoryController#SaveCategory', 'as' => 'savecategory']);
Route::any('/viewcategory/{id}', ['uses' => 'Category\CategoryController#ViewCategory', 'as' => 'viewcategory']);
Route::any('/editcategory/{id}', ['uses' => 'Category\CategoryController#EditCategory', 'as' => 'editcategory']);
Route::any('/updatecategory', ['uses' => 'Category\CategoryController#UpdateCategory', 'as' => 'updatecategory']);
Route::any('/deletecategory', ['uses' => 'Category\CategoryController#DeleteCategory', 'as' => 'deletecategory']);
Route::any('/deleteselectedcategorylvl1', ['uses' => 'Category\CategoryController#DeleteSelectedCategoryLvl1', 'as' => 'deleteselectedcategorylvl1']);
Route::any('/view-subcategory-level3-manage', ['uses' => 'Category\CategoryController#ViewSubCategoryLvl3_Manage', 'as' => 'view-subcategory-level3-manage']);
Route::any('/view-subcategory-level4-manage', ['uses' => 'Category\CategoryController#ViewSubCategoryLvl4_Manage', 'as' => 'view-subcategory-level4-manage']);
//Sub Category
Route::any('/category-level2', ['uses' => 'Category\CategoryController#ManageCategoryLvl2', 'as' => 'category-level2']);
Route::any('/savesubcategory', ['uses' => 'Category\CategoryController#SaveSubCategory', 'as' => 'savesubcategory']);
Route::any('/viewsubcategory/{id}', ['uses' => 'Category\CategoryController#ViewSubCategory', 'as' => 'viewsubcategory']);
Route::any('/editsubcategory/{id}', ['uses' => 'Category\CategoryController#EditSubCategory', 'as' => 'editsubcategory']);
Route::any('/updatesubcategory', ['uses' => 'Category\CategoryController#UpdateSubCategory', 'as' => 'updatesubcategory']);
Route::any('/deletesubcategory', ['uses' => 'Category\CategoryController#DeleteSubCategory', 'as' => 'deletesubcategory']);
Route::any('/deleteselectedcategorylvl2', ['uses' => 'Category\CategoryController#DeleteSelectedCategoryLvl2', 'as' => 'deleteselectedcategorylvl2']);
//Sub Category Lvl3
Route::any('/category-level3', ['uses' => 'Category\CategoryController#ManageCategoryLvl3', 'as' => 'category-level3']);
Route::any('/savesubcategorylvl3', ['uses' => 'Category\CategoryController#SaveSubCategoryLvl3', 'as' => 'savesubcategorylvl3']);
Route::any('/view-subcategory-level3/{id}', ['uses' => 'Category\CategoryController#ViewSubCategoryLvl3', 'as' => 'view-subcategory-level3']);
Route::any('/edit-subcategory-level3/{id}', ['uses' => 'Category\CategoryController#EditSubCategoryLvl3', 'as' => 'edit-subcategory-level3']);
Route::any('/updatesubcategorylvl3', ['uses' => 'Category\CategoryController#UpdateSubCategoryLvl3', 'as' => 'updatesubcategorylvl3']);
Route::any('/deletesubcategorylvl3', ['uses' => 'Category\CategoryController#DeleteSubCategoryLvl3', 'as' => 'deletesubcategorylvl3']);
Route::any('/deleteselectedcategorylvl3', ['uses' => 'Category\CategoryController#DeleteSelectedCategoryLvl3', 'as' => 'deleteselectedcategorylvl3']);
//Sub Category Lvl4
Route::any('/category-level4', ['uses' => 'Category\CategoryController#ManageCategoryLvl4', 'as' => 'category-level4']);
Route::any('/savesubcategorylvl4', ['uses' => 'Category\CategoryController#SaveSubCategoryLvl4', 'as' => 'savesubcategorylvl4']);
Route::any('/view-subcategory-level4/{id}', ['uses' => 'Category\CategoryController#ViewSubCategoryLvl4', 'as' => 'view-subcategory-level4']);
Route::any('/edit-subcategory-level4/{id}', ['uses' => 'Category\CategoryController#EditSubCategoryLvl4', 'as' => 'edit-subcategory-level4']);
Route::any('/updatesubcategorylvl4', ['uses' => 'Category\CategoryController#UpdateSubCategoryLvl4', 'as' => 'updatesubcategorylvl4']);
Route::any('/deletesubcategorylvl4', ['uses' => 'Category\CategoryController#DeleteSubCategoryLvl4', 'as' => 'deletesubcategorylvl4']);
Route::any('/deleteselectedcategorylvl4', ['uses' => 'Category\CategoryController#DeleteSelectedCategoryLvl4', 'as' => 'deleteselectedcategorylvl4']);
//Import Category
Route::any('/categoryimport', ['uses' => 'Category\CategoryController#CategoryImport', 'as' => 'categoryimport']);
Route::any('/importcategorylvl1', ['uses' => 'Category\CategoryController#ImportCategoryLvl1', 'as' => 'importcategorylvl1']);
Route::any('/importcategorylvl2', ['uses' => 'Category\CategoryController#ImportCategoryLvl2', 'as' => 'importcategorylvl2']);
Route::any('/importcategorylvl3', ['uses' => 'Category\CategoryController#ImportCategoryLvl3', 'as' => 'importcategorylvl3']);
Route::any('/importcategorylvl4', ['uses' => 'Category\CategoryController#ImportCategoryLvl4', 'as' => 'importcategorylvl4']);
/********** Model **********/
Route::any('/addmodel', ['uses' => 'ModelComponent\ModelController#AddModel', 'as' => 'addmodel']);
Route::any('/addmodelprocess', ['uses' => 'ModelComponent\ModelController#AddModelProcess', 'as' => 'addmodelprocess']);
Route::any('/importmodel', ['uses' => 'ModelComponent\ModelController#ImportModel', 'as' => 'importmodel']);
Route::any('/importmodelprocess', ['uses' => 'ModelComponent\ModelController#ImportModelProcess', 'as' => 'importmodelprocess']);
Route::any('/managemodel', ['uses' => 'ModelComponent\ModelController#ManageModel', 'as' => 'managemodel']);
Route::any('/editmodel/{id}', ['uses' => 'ModelComponent\ModelController#EditModel', 'as' => 'editmodel']);
Route::any('/updatemodel', ['uses' => 'ModelComponent\ModelController#UpdateModel', 'as' => 'updatemodel']);
Route::any('/deletemodel', ['uses' => 'ModelComponent\ModelController#DeleteModel', 'as' => 'deletemodel']);
Route::any('/deleteselectedmodel', ['uses' => 'ModelComponent\ModelController#DeleteSelectedModel', 'as' => 'deleteselectedmodel']);
/********** Tech Specs **********/
Route::any('/addtechspecsformat', ['uses' => 'TechSpecs\TechSpecsController#AddSpecsFormat', 'as' => 'addtechspecsformat']);
Route::any('/addtechspecsformatprocess', ['uses' => 'TechSpecs\TechSpecsController#AddSpecsFormatProcess', 'as' => 'addtechspecsformatprocess']);
Route::any('/specsgetmodel', ['uses' => 'TechSpecs\TechSpecsController#GetModel', 'as' => 'specsgetmodel']);
Route::any('/managespecsformat', ['uses' => 'TechSpecs\TechSpecsController#ManageSpecsFormat', 'as' => 'managespecsformat']);
Route::any('/viewspecsformat', ['uses' => 'TechSpecs\TechSpecsController#ViewSpecsFormat', 'as' => 'viewspecsformat']);
Route::any('/editspecsformat/{id}', ['uses' => 'TechSpecs\TechSpecsController#EditSpecsFormat', 'as' => 'editspecsformat']);
Route::any('/deletespecsformat', ['uses' => 'TechSpecs\TechSpecsController#DeleteSpecsFormat', 'as' => 'deletespecsformat']);
Route::any('/deleteselectedformat', ['uses' => 'TechSpecs\TechSpecsController#DeleteSelectedSpecsFormat', 'as' => 'deleteselectedformat']);
/********** Products **********/
Route::any('/products', ['uses' => 'Products\ProductController#ManageProducts', 'as' => 'products']);
Route::any('/saveproduct', ['uses' => 'Products\ProductController#SaveProduct', 'as' => 'saveproduct']);
Route::any('/viewproduct/{id}', ['uses' => 'Products\ProductController#ViewProduct', 'as' => 'viewproduct']);
Route::any('/editproduct/{id}', ['uses' => 'Products\ProductController#EditProduct', 'as' => 'editproduct']);
Route::any('/updateproduct', ['uses' => 'Products\ProductController#UpdateProduct', 'as' => 'updateproduct']);
Route::any('/deleteproduct', ['uses' => 'Products\ProductController#DeleteProduct', 'as' => 'deleteproduct']);
Route::any('/productsgetbrand', ['uses' => 'Products\ProductController#ProductsGetBrandDetails', 'as' => 'productsgetbrand']);
Route::any('/productgetsku', ['uses' => 'Products\ProductController#GetSKU', 'as' => 'productgetsku']);
//Route::any('/getselectedproductcat', ['uses' => 'Products\ProductController#GetSelectedProdCat', 'as' => 'getselectedproductcat']);
Route::any('/productscategory', ['uses' => 'Products\ProductController#GetCategory', 'as' => 'productscategory']);
Route::any('/productsgetmodel', ['uses' => 'Products\ProductController#GetModel', 'as' => 'productsgetmodel']);
Route::any('/productgettechspecs', ['uses' => 'Products\ProductController#ProductGetSpecs', 'as' => 'productgettechspecs']);
Route::any('/deleteselectedproducts', ['uses' => 'Products\ProductController#DeleteSelectedRecords', 'as' => 'deleteselectedproducts']);
/********** Attribute **********/
//Attribute
Route::any('/attribute', ['uses' => 'Attribute\AttributeController#ManageAttributes', 'as' => 'attribute']);
Route::any('/save-attribute-set', ['uses' => 'Attribute\AttributeController#SaveAttributeSet', 'as' => 'save-attribute-set']);
Route::any('/save-attribute', ['uses' => 'Attribute\AttributeController#SaveAttribute', 'as' => 'save-attribute']);
});
//Scraper
Route::group(['prefix' => 'vendorpanel', 'middleware' => 'vendorpanel'], function() {
//Login
Route::any('/', ['uses' => 'Scraper\ScraperController#getLogin', 'as' => 'login']);
Route::any('processlogin-scraper', ['uses' => 'Scraper\ScraperController#doLogin', 'as' => 'processlogin-scraper']);
//dashboard
Route::any('vendor-dashboard', ['uses' => 'Scraper\ScraperController#getDashboard', 'as' => 'vendor-dashboard']);
Route::any('/logout-vendor', ['uses' => 'Scraper\ScraperController#logout', 'as' => 'logout-vendor']);
//Scraping
Route::any('/process-scraping', ['uses' => 'Scraper\ScraperController#doScraping', 'as' => 'process-scraping']);
});
//Frontend
Route::get('/', function () {
return view('frontend.welcome');
});
});
route: web.php routes definitions
Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function() {
Route::get('/home', 'AdminController#home');
Route::get('/manage', 'AdminController#manage');
});
sidebar links routes is missing
<li class="nav-item">
<a href="{{route('admin.manage')}}" class="nav-link">
<i class="fa fa-circle-o nav-icon"></i>
<p>Employees</p>
</a>
</li>
Because you don't named routes. Try this code.
Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function() {
Route::get('/home', 'AdminController#home')->name('admin.home');
Route::get('/manage', 'AdminController#manage')->name('admin.manage');
});
See also documentation https://laravel.com/docs/5.6/routing#named-routes
You can also add as parameter in grouping
Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'as' => 'admin.'], function() {
Route::get('/home', 'AdminController#home')->name('home');
Route::get('/manage', 'AdminController#manage')->name('manage');
});
My site is running with multiple subdomains on domain exa.com for example, now I need to set up another domain is exa1.com. So How can I update my route file to implement it?
Route::group(
array(
'domain' => '{business_slug}.exa.com',
'middleware' => 'verify_domain'
), function() {
Route::get('', [
'as' => 'index',
'uses' => 'HomeController#index'
]);
Route::get('user', [
'as' => 'user.index',
'middleware' => 'auth',
'uses' => 'UserController#index'
]);
...
});
Try this:
<?php
$applicationRoutes = function() {
Route::get('/', [
'as' => 'index',
'uses' => 'HomeController#index'
]);
Route::get('user', [
'as' => 'user.index',
'middleware' => 'auth',
'uses' => 'UserController#index'
]);
};
Route::group(['middleware' => 'verify_domain'], function() {
Route::group(
[
'domain' => '{business_slug}.exa.com',
], $applicationRoutes);
Route::group(
[
'domain' => '{business_slug}.exa1.com',
], $applicationRoutes);
});
I created a form:
{{ Form::open(array('route' => 'cart.add')) }}
I have this in my routes.php file:
Route::post( 'cart/add', array('https' => true, 'uses' => 'CartController#addToCart', 'as' => 'cart.add'));
Yet, the resulting HTML is:
<form method="POST" action="http://localhost/cart/add" accept-charset="UTF-8">
I was expecting:
<form method="POST" action="https://localhost/cart/add" accept-charset="UTF-8">
because the route is defined as needing HTTPS.
What am I missing?
My problem was that this:
Route::post( 'cart/add', array('https' => true, 'uses' => 'CartController#addToCart', 'as' => 'cart.add'));
Had to be this:
Route::post( 'cart/add', array('https', 'uses' => 'CartController#addToCart', 'as' => 'cart.add'));