Feb 12, 2018
0
Level 2
Constructors in Controllers arent supposed to use values set from Middleware, correct?
It seems it loads as:
- Controller:: __construct
- Middleware
- Controller::function
So - lets assume i have middleware registering an object of 'current_user'..
__construct(){
$this->user = \App::make('current_user');
}
.. wont work; even if middleware registers a service to the container, Correct?
So i I am trying to avoid crazy cod of having to type \App::make() a thousand times, so I have simply made a function like so:
public function currentUser(){
return \App::make('current_user');
}
...in the controller; and in my individual controller functions simply use
$this->currentUser();
Correct?
(yeah my code works, just making sure i understand it)
Please or to participate in this conversation.