Search code examples
phplaravelactioncontrollers

Add method for all controllers Laravel


I have a layout where the footer is common for all sections. That footer has to make different methods but I do not know how to implement in all controllers at once.

I thought I could implement the constructor in the BaseController, but I think that is a bad idea.


Solution

  • Here is how I would do this... you're simply extending BaseController and calling it BadassController, then extending that in your controllers.

    class BadassController extends BaseController {}