Тёмный

Laravel User Multi-Tenancy 1/3: Auto-Setting User ID 

Laravel Daily
Подписаться 145 тыс.
Просмотров 10 тыс.
50% 1

Опубликовано:

 

30 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 33   
@Sahrokh
@Sahrokh 2 года назад
Yes please keep covering multi-tenancy, I am VERY interested about it!
@seppdaniel
@seppdaniel 2 года назад
Personally prefer doing auth()->user()->projects()->create($validated);
@nipuntharuksha3070
@nipuntharuksha3070 2 года назад
I do the same . But I think this runs another extra query . So what’s your idea about that .
@hristijans
@hristijans 2 года назад
Another way would be in the StoreProjectRequest to override prepareForValidation method public function prepareForValidation() { $this->merge(['user_id' => auth()->id]); }
@sauravjain6135
@sauravjain6135 2 года назад
In controller or in model
@hristijans
@hristijans 2 года назад
@@sauravjain6135 In the Request class.
@JouvaMoufette
@JouvaMoufette 2 года назад
I like the idea of using that creating callback to do something such as setting up additional fields or creating a related child record. I don't like the idea of utilizing auth() in there, since, like you mentioned, this could come from command line tools.
@Tikey1989
@Tikey1989 2 года назад
I am of your opinion. i think only controllers, requests and Http-Middlewares shuld be aware of the auth functionality.
@yvanjordankengni3940
@yvanjordankengni3940 Год назад
you are the best thanks
@SalomDunyoIT
@SalomDunyoIT 2 года назад
Getting deeper and deeper :) thanks!
@mindteaserhub
@mindteaserhub Год назад
Hi, thanks for this really nice tutorial. Please let me know how do give access to admin role and also parent account of the user to create, add, delete using this method? Thank you
@hosamgnaba3205
@hosamgnaba3205 2 года назад
nice lesson mate, thank you
@eloquent2200
@eloquent2200 2 года назад
Thank you!
@jeFFFairson
@jeFFFairson 2 года назад
Hello, quick question, instead of using the model boot method is it more pertinent to use an observer to do it and gather all the project events logic in the same class ? Is it a "best practice" to use an observer ?
@LaravelDaily
@LaravelDaily 2 года назад
Yes it could be done in the observer as well. But the next few lessons in upcoming days will show why IN THIS CASE observers are not the best solutions.
@jeFFFairson
@jeFFFairson 2 года назад
@@LaravelDaily thanks, can't wait to see the rest (If i'm not buying your course before as I totally need these informations for an ongoing project ;) )
@DanielŚmigiela
@DanielŚmigiela 2 года назад
i using observer class to store auth user id to db :)
@DeTechDivus
@DeTechDivus 2 года назад
Hello, whats the difference between setting user_id automatically in creating and as a setter? I guess if someone else edit's it it would change the user as well, but just asking? :D
@LaravelDaily
@LaravelDaily 2 года назад
Not much difference, it's just personal preference.
@marczello8162
@marczello8162 2 года назад
I have video idea for you. Create User model and relations to it for creating relationships (as in Facebook). Recently I received that task and I think it can be achieve better.
@LaravelDaily
@LaravelDaily 2 года назад
I don't really understand the problem here: you want me to show how belongsTo(User::class) relationship works? I think it's very basic, on my channel I'm trying not to cover very basic things.
@kingstalker
@kingstalker 2 года назад
Maybe he means like the family relationship facebook has where you have a drop down and choose brother/sister
@LaravelDaily
@LaravelDaily 2 года назад
Maybe, @Marczello please explain in more details.
@marczello8162
@marczello8162 2 года назад
@@kingstalker No. My problem: if we have table "relationships" with "user_id" and "friend_id" we can get all user friends. In example: "user_id" is User X and "friend_id" is User Y. We can create relation which get User X friends, but if we want to get User Y friends same "belongs to" not works, because they have another columns names.
@LaravelDaily
@LaravelDaily 2 года назад
Sorry I still don't understand what do you mean by "User Y friends". Can you create a demo project on Github and invite me (username PovilasKorop) and then I will try to reproduce and. help.
@rianwidianto
@rianwidianto 2 года назад
Im using traits for that purpose
@PsyHooZ
@PsyHooZ 2 года назад
creating method in some companies count as anti-patterns, better use prepared trait, or set up needed properties in request class. Or use service class for creating records and in this class write logic, today you need add only user_ID, tomorrow you need to do some other calculations
@easyvideott7505
@easyvideott7505 2 года назад
You are explaining multi-tenancy on a single Database? True or False?
@LaravelDaily
@LaravelDaily 2 года назад
In these free videos, yes. In full course, second part is about multiple DB.
@DANJ93Mort
@DANJ93Mort 2 года назад
Another method is observer
@himak21
@himak21 2 года назад
I waiting who writes this method ;)
Далее
g-toilet fights juggernaut (skibidi toilet 77)
00:59
Просмотров 1,6 млн
无意间发现了老公的小金库 #一键入戏
00:20
Laravel 11: Multi-Tenancy with Multiple Databases
8:23
Laravel Team Multi-Tenancy 3/3: Tenant Subdomains
11:33
g-toilet fights juggernaut (skibidi toilet 77)
00:59
Просмотров 1,6 млн