Laravel Base Controller: Add Custom Logic (+ Splade Surprise)

preview_player
Показать описание
Let's see how Eddy Management uses the Base Controller to add some common logic for other Controllers.

- - - - -
Support the channel by checking out my products:

- - - - -
Other places to follow:
Рекомендации по теме
Комментарии
Автор

i prefer to have Team::current() and User::current() static methods in my models instead of putting methods for them in the controllers. this allows getting them from anywhere in the application easily and with the same syntax for both of them

itsmillrtime
Автор

It depends on a project, but I prefer move $this->user(); $this->team(); to traits as it could be reusable in every class, not only controllers

nick-test
Автор

I think that 'protected function team()` is a bit problematic too. Yes you save few characters, but just by looking at it in the controller, it's not immediately clear what exactly 'team' is. Whereas `auth()->user->currentTeam` is kind of obvious.

vytautasgaldikas
Автор

Please make a video on Laravel Octane.

speckyfahad