Tim van Uum
Tim van Uum

Reputation: 1903

Laravel route parameter in AppServiceProvider

I have the following route:

Route::get('{organisation}', 'Organisation\HomeController@index');

Now I need {organisation} in the AppServiceProvider my code there is as follows:

view()->composer('organisation.layout', function($view) {
        $view->with('categories', CategoryHelper::getCategoriesByOrganisation($organisation));
});

$organisation has to become the route parameter. I need to have categories available in the view all the time.

I've tried with Input::get('organisation'); but no luck.

Is this the best approach? If yes, how do I get the route parameter?

Upvotes: 0

Views: 1034

Answers (1)

chanafdo
chanafdo

Reputation: 5124

Try this

\App::make('request')->route()->getParameter('organisation')

Is this the best approach. It depends on what you are doing.

If you simply loading the categories by organisation when someone is viewing an organization this should do fine.

Upvotes: 1

Related Questions