Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set variable for a controller - Laravel 4

So here is the thing. I need someway to set a global variable for the whole controller.

I need it because all of the actions in the controller is going to need to receive the data via the GET method.

I thought that maybe placing it in the __construct will make it work like this:

public function __construct()
{
    $this->team_id = Input::get('team_id');
}

But it says team_id is not found....

Thanks for your help, Ara

like image 791
Ara Sivaneswaran Avatar asked Feb 04 '26 18:02

Ara Sivaneswaran


1 Answers

Do you set a global variable name $team_id in your controller class before set it into __construct ? Because it will fail if you want to set an unknown variable.

like image 173
netvision73 Avatar answered Feb 07 '26 09:02

netvision73



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!