Laravel same route in multiple groups and inside multiple controllers - laravel
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');
});
});
Related
Problems in implement reCaptcha V3 in laravel
I am using Google reCaptcha v3. I am trying to implement it onto my profile page.It's load and shown in my page ,but when I want to verify it ,it does not work ,I am using this package:https://github.com/RyanDaDeng/laravel-google-recaptcha-v3#settings in this config : 'secret_key' => env('RECAPTCHA_V3_SECRET_KEY', '6LcqC'), 'site_key' => env('RECAPTCHA_V3_SITE_KEY', '6LcqnrO-K-xb'), in this blade : <form> {!! GoogleReCaptchaV3::renderOne('contact_us_id','contact_us') !!} </form> in my controller: public function get_data_edit(Request $request) { $request->validate( [ 'phone' => ['required', 'max:11', new phone], 'year' => 'nullable|numeric', 'month' => 'nullable|numeric|max:12', 'day' => 'nullable|numeric|max:31', 'sex' => 'nullable|boolean', 'marital_status' => 'nullable|boolean', 'f_name' => 'required|max:15', 'l_name' => 'required|max:20', 'job' => 'nullable|string', 'email' => 'nullable|email', 'national_code' => 'nullable|min:10|max:10', 'family_role' => 'nullable|string', 'g-recaptcha-response' => [new GoogleReCaptchaV3ValidationRule('contact_us')] ], [] ); where is my problem ?
Route not defined in laravel
I'm getting this error ErrorException in UrlGenerator.php line 304: Route [customer.signup] not defined. (View: C:\xampp\htdocs\ecomm\app\Modules\Templates\Resources\Views\layouts\public.blade.php) (View: C:\xampp\htdocs\ecomm\app\Modules\Templates\Resources\Views\layouts\public.blade.php) but as far as I know my routes is all correct. My public.blade.php <li class="dropdown"> <i class="fa fa-user" aria-hidden="true"></i> User Management <span class="caret"></span> <ul class="dropdown-menu"> <li>Sign up</li> <li>Login</li> <li role="separator" class="divider"></li> <li>Logout</li> </ul> </li> my routes Route::get('/shipping-info', [ 'uses' => 'OpenController#shippingInfo', 'as' => 'cart.shippingInfo' ]); Route::get('/signup', [ 'uses' => 'OpenController#signup', 'as' => 'customer.signup' ]); Route::delete('/product/deleting/{id}', [ 'uses' => 'OpenController#deleting', 'as' => 'deleting' ]); Route::get('/login', [ 'uses' => 'OpenController#login', 'as' => 'client.login' ]); Route::get('/shopping-cart', [ 'uses' => 'OpenController#shoppingCart', 'as' => 'cart.shop' ]); Route::get('/product/update-item/{id}', [ 'uses' => 'OpenController#updateProduct', 'as' => 'cart.update' ]); Route::get('/', [ 'uses' => 'OpenController#index', 'as' => 'index', ]); Route::get('/{id}', 'OpenController#content'); Route::get('gallery/{title}', 'OpenController#galleryCategory'); Route::get('/product/{id}', [ 'uses' => 'OpenController#product', 'as' => 'shop.product' ]); Route::post('/product/update-cart/{id}', [ 'uses' => 'OpenController#updateCart', 'as' => 'cart.updateCart' ]); Route::put('/product/update-qty/{id}', [ 'uses' => 'OpenController#newQty', 'as' => 'new.qty' ]); My signup method in OpenController public function signup() { echo "OpenController Signup"; }
You have to clear your route cache, if you've already run route:cache before: php artisan route:clear
Multiple domains and subdomains (laravel 5)
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); });
FatalErrorException in HtmlServiceProvider.php line 36: laravel
I am using laravel 5.2 and I am getting following error FatalErrorException in HtmlServiceProvider.php line 36: Call to undefined method Illuminate\Foundation\Application::bindShared() my app.php file is <?php return [ 'env' => env('APP_ENV', 'production'), 'debug' => env('APP_DEBUG', false), 'url' => 'http://localhost', 'timezone' => 'UTC', 'locale' => 'en', 'fallback_locale' => 'en', 'key' => env('APP_KEY'), 'cipher' => 'AES-256-CBC', 'log' => env('APP_LOG', 'single'), 'providers' => [ /* * Laravel Framework Service Providers... */ Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Bus\BusServiceProvider::class, Illuminate\Cache\CacheServiceProvider::class, Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, Illuminate\Cookie\CookieServiceProvider::class, Illuminate\Database\DatabaseServiceProvider::class, Illuminate\Encryption\EncryptionServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class, Illuminate\Redis\RedisServiceProvider::class, Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, Illuminate\Session\SessionServiceProvider::class, Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, 'Illuminate\Html\HtmlServiceProvider', /* * Application Service Providers... */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, ], 'aliases' => [ 'App' => Illuminate\Support\Facades\App::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, 'Cache' => Illuminate\Support\Facades\Cache::class, 'Config' => Illuminate\Support\Facades\Config::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class, 'Crypt' => Illuminate\Support\Facades\Crypt::class, 'DB' => Illuminate\Support\Facades\DB::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Event' => Illuminate\Support\Facades\Event::class, 'File' => Illuminate\Support\Facades\File::class, 'Gate' => Illuminate\Support\Facades\Gate::class, 'Hash' => Illuminate\Support\Facades\Hash::class, 'Lang' => Illuminate\Support\Facades\Lang::class, 'Log' => Illuminate\Support\Facades\Log::class, 'Mail' => Illuminate\Support\Facades\Mail::class, 'Password' => Illuminate\Support\Facades\Password::class, 'Queue' => Illuminate\Support\Facades\Queue::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class, 'Redis' => Illuminate\Support\Facades\Redis::class, 'Request' => Illuminate\Support\Facades\Request::class, 'Response' => Illuminate\Support\Facades\Response::class, 'Route' => Illuminate\Support\Facades\Route::class, 'Schema' => Illuminate\Support\Facades\Schema::class, 'Session' => Illuminate\Support\Facades\Session::class, 'Storage' => Illuminate\Support\Facades\Storage::class, 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, 'Form' => 'Illuminate\Html\FormFacade', 'Html' => 'Illuminate\Html\HtmlFacade', ], ]; And signup_form.blade.php file is <h1>signupform</h1> <div class="signup-form"> {!! Form::open() !!} {!! Form::text('email','',array('class'=>'email','id'=>"email","placeholder"=>'Email address'))!!} {!! Form::close() !!} </div> And my routes.php file <?php Route::get('/', function () { return view('welcome'); }); Route::get('home', function () { echo 'welome home'; }); Route::get('signup', 'Auth\HomeController#signupform'); whenever i open the form in browser it shows the above error.
You need to remove: 'Illuminate\Html\HtmlServiceProvider', and 'Form' => 'Illuminate\Html\FormFacade', 'Html' => 'Illuminate\Html\HtmlFacade', form your `config/app.php then remove from your composer.json illuminate/html then add to your composer.json: "laravelcollective/html": "5.*" in require section then run composer install And further you need to follow instructions for https://laravelcollective.com/docs/5.1/html#installation to complete this package installation EDIT IT might be not working at this moment because of this: https://github.com/LaravelCollective/html/issues/133 - it will be probably solved after merging this PR: https://github.com/illuminate/html/pull/31/files
First, in the composer.json file need to replace: "illuminate/html": "^5.0" with "laravelcollective/html":"5.2.*" Next you need update the composer from the terminal by typing this command in your terminal: composer update. Next, in the config/app.php file, you replace the: 'Illuminate\Html\HtmlServiceProvider::class'` with 'Collective\Html\HtmlServiceProvider::class' Next you replace these two classes aliases: 'Form' => Illuminate\Html\FormFacade::class, 'Html' => Illuminate\Html\HtmlFacade::class, with 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, Lastly, you need to update your routes.php file by replacing the 'web' middleware with: Route::group(['middleware' => ['web']], function () use ($router) { $router->resource('blogs', 'BlogsController'); });
Here's a tutorial on LaravelCollective.com.
The "trick" that worked for me is the one mentioned above because Illuminate/HTML package has been deprecated: Use:laravelcollective/html https://stackoverflow.com/a/34991188/3327198 In the terminal (CLI): composer require laravelcollective/html Add this lines in config/app.php IN PROVIDERS GROUP: Collective\Html\HtmlServiceProvider::class, IN ALIASES GROUP: 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class,
This trick worked for me Change the name of all "bindShared" functions into "singleton" in the vendor\illuminate\html\HtmlServiceProvider.php file For example: Change $this->app->bindShared('html', function($app) { return new HtmlBuilder($app['url']); }); into $this->app->singleton('html', function($app) { return new HtmlBuilder($app['url']); });
Is it possible to configure routes in a container (empty/non-routing parent)?
I'm creating an authentication module to deal with the login/logout of users into the website. I want to keep the paths simple: https://example.com/login https://example.com/logout But, for some functions within the application/module, it would make sense to me to set up the two routes under some kind of parent: 'routes' => array( 'auth' => array( 'type' => 'Literal', 'options' => array( 'route' => '', ), 'may_terminate' => true, 'child_routes' => array( 'login' => array( 'type' => 'Literal', 'options' => array( 'route' => '/login', 'defaults' => array( 'controller' => 'Base\Controller\Authentication', 'action' => 'login', ), ), 'may_terminate' => true, ), 'logout' => array( 'type' => 'Literal', 'options' => array( 'route' => '/logout', 'defaults' => array( 'controller' => 'Base\Controller\Authentication', 'action' => 'logout', ), ), 'may_terminate' => true, ), ), ), The problem is - without any route in the parent, I can't get a match on either of the child routes (/login and /logout return 404 with routing errors). If I do put a route in the parent, like /auth then the urls only match as /auth/login and /auth/logout. I don't want the parent to interfere with routing in other modules - for example, the "home" route at '/' is already defined in a different module and I don't want to replace or modify that. About the only thing I have found on the internet similar to what I'm trying is a resolved bug report from 2012. Is there a way to define a non-routing parent that can hold routable children in ZF2 configuration?
'routes' => array( 'auth' => array( 'type' => 'Literal', 'options' => array( 'route' => '/', ), 'may_terminate' => true, 'child_routes' => array( 'login' => array( 'type' => 'Literal', 'options' => array( 'route' => 'login', 'defaults' => array( 'controller' => 'Base\Controller\Authentication', 'action' => 'login', ), ), 'may_terminate' => true, ), 'logout' => array( 'type' => 'Literal', 'options' => array( 'route' => 'logout', 'defaults' => array( 'controller' => 'Base\Controller\Authentication', 'action' => 'logout', ), ), 'may_terminate' => true, ), ), ),