search

Home  >  Q&A  >  body text

How to get the current controller instance in laravel?

Some properties are set in BaseController, User, Param, etc. How to call it from other location?

For example, when an administrator updates user information, logs need to be recorded, so the user.update event is triggered

$response = Event::fire('user.update',array($user));

Then in UserHandler@update, you need to obtain the current user's id, role and other information, which is in BaseControler

public $user;
public $param;
...
__construct(){
    $this->user = Auth::user();
    $this->param = Input::all();
    ...
}    

How to get the current controller instance in UserHandler@update to access parameters such as $user, $param?

淡淡烟草味淡淡烟草味2838 days ago549

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-05-16 16:58:29

        use App\Http\Controller;
        class UserHandler extends baseController{
    
        }
    

    reply
    0
  • Cancelreply