php - Laravel retrieve param in class constructor -


this question has answer here:

here route:

route::controller('/app/{companyid}/', 'homecontroller', array('before' => 'auth')); 

how can retrieve $companyid argument in __constructor avoid retrieving separate in actions?

if want parameters in __construct of controller this:

class homecontroller extends \basecontroller {     public function __construct()     {         $this->routeparamters = route::current()->parameters();     } } 

it return key value list of parameters route (ex: ['companyid' => '1']) @see \illuminate\routing\route

you can specific parameter using getparameter() or parameter() methods.

note: i'm not sure such great idea tho. there might more elegant way solve or better approach problem.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -