[Live-Coding] Laravel Multi-Tenancy with Single Trait

preview_player
Показать описание
A demo-project to show you how easy it is to add multi-tenancy to Laravel project. First we do that with observers, but then make it more flexible with a trait.

- - - - -

- - - - -
Рекомендации по теме
Комментарии
Автор

an important note here is that the trait's boot method name must follow the pattern boot+trait_name in order for the method to be called automatically inside the model

bashardlaleh
Автор

Even though this video is quite old now, it's still one of the best introductions to multi-tenancy for Laravel available. The problem is between 2020 and 2021 everyone went on tangent to try and do fancy stuff with multi-tenancy - new plugins - new packages - multi-data - tenant identification by domain name. The bottom line is for most basic multi-tenancy apps scoping and observers are more than enough.

eugenevandermerwe
Автор

Yep! Definitely useful, and added to my list of things to implement. Thank you!

bernardonigbinde
Автор

This is just pure perfection and simplicity for something I needed to implement today. Thank you

Chim
Автор

Brilliant tutorial. Thanks!


One thing that caught me out: The boot method suffix MUST match the class name.


trait MultitenantableTrait {
public static function bootMultitenantableTrait(). //The method name here is boot{classname}


...not
trait MultitenantableTrait {
public static function bootMultitenantable() //no 'trait' on the method name


I know this is probably super obvious to most people, but it took me quite a while to work out what was going on! :-)

stealmymarketing
Автор

Excellent demonstration, thank you so much for this video

johndawkins
Автор

Wonderful... Thank you for making this.

sagardolui
Автор

Very good video! Thanks and keep going!

PRDT
Автор

Great video, if you want to allow for joins where multiple tables will have the created_by_user_id, you can add this to your trait.

. '.created_by_user_id', auth()->id);

Keep up the good work!

KyleReierson
Автор

YOU ARE A M A Z I N G Tks so much, you saved my life <3

wellingtonbarbosa
Автор

Awesome! Coool Man. Thank you very much for this tutorial.

ridwanhaqi
Автор

Yeah ...so far....great video Man. I am suscribed.

GrupoINTIWeb
Автор

Also we can put the belongs to user relation in that Trait

prabhatthapa
Автор

U are just amazing is there any package out there for this ?

fullstack
Автор

Thank you so much, useful stuff I am going to implement in my current project, Could you please tell me the chrome add-ons, which you are using for form filllup

RahulKumar-rktf
Автор

Can we implement the same idea with multi databases from single code base?
Thank you for the great tutorial

SopanaAllah
Автор

Thanks for the video! Where to learn deeper about Observers?

igoreksazonov
Автор

So helpful thank you sooo much. Can you please make one using hyn/multi-tenancy package

hamzabouk
Автор

Hello, excellent explanation. Can I implement the Multi-Tenancy part in my project?

s.camilogomez
Автор

Great example. The only thing I dont get is how the bootMultitenantable() function is called. Is it because Larabel executes everyrhing that starts with bootXxxxc?

parijke