vendredi 23 février 2018

Is it possible to inject a variable into route group which is common for all inside routes?

i have categories variable which basically gets all the data from category table and it is common for all the pages. So far i am injecting it to view from the controller.

I want to know is there anyway in the routes where i can specify the category and it will be available for all the routes inside that group rather then injecting it into view from controller ??

Something like this

 Route::group(['namespace' => 'Frontend'], function ($category = Category::all()) {
        Route::get('/', 'HomeController@welcome')->name('welcome');
        Route::get('/c/{slug}','HomeController@category')->name('frontend.category');
        .......
      ..........
    });

Is it possible ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2CenNI8
via IFTTT

Aucun commentaire:

Enregistrer un commentaire