Support the ongoing development of Laravel.io →
Requests Input Installation
Last updated 7 months ago.
0

i'm not sure about the controller construct but you CAN send to the controller method. http://laravel.com/docs/5.1/routing#route-parameters

0

yes route parameters can send to the controller method, but I can't find a way that route parameters can send to the controller construct.

0
Solution

found a solution

[ laravel 5.1 ] ~ edited


Route::group(['prefix' => '{sites}', 'as' => 'sites.'], function () {

        Route::get('/', [
            'as' => 'index', 
            'uses' => '[email protected]'
        ])
        ->where('sites', '[0-9A-Za-z_.]+');

    });

});

SitesController.php


    public function __construct(Request $request)
    {

    	print_r($request->sites);

    }

hope this is useful for others

Last updated 7 years ago.
0

interesting

0

but then if it is a parameter, you can use $request without doing any "hack".. but maybe if you tell us what you are trying to do people can recommend a better approach?

0

I'm trying to get parameter {sites} from route and send to _construct controller, so I can check that parameter globally and set var global in that controller.

I change my code and use middleware.

0

Sign in to participate in this thread!

LaraJobs

Your banner here too?

gzai gzai Joined 12 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.