Тёмный
No video :(

Eloquent Polymorphic Relations: Properly Explained 

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

One video from my course "Eloquent: Expert Level": laraveldaily.t...
Polymorphic relations are one of the most difficult concept to understand for junior developers, and I tried to do it with a real-life example.

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

 

22 авг 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 45   
@kevinnacario359
@kevinnacario359 3 года назад
Thank you so much!!! Was able to get the point of Polymorphic right of the bat. Definitely worth it. Hoping I could take your course but it seems its too expensive for me at the moment.
@heitorferreira964
@heitorferreira964 2 года назад
Thank you, your explanation save my day, I was very confused at beginning and I watched this lesson and debug many times until got the trick how it works under the hood.
@wtalkie
@wtalkie 5 месяцев назад
Great explanation as always. You're the go-to channel for anything laravel-related.
@shafqatalinawaz6218
@shafqatalinawaz6218 2 года назад
Thanks for sharing. I now understand perfectly how to use polymorphic relationships.
@andywong2244
@andywong2244 Год назад
i was able to get the concept behind polymorphism at the 1st 3 minutes of your explanation Povilas! you teach very well!
@reesss4
@reesss4 Год назад
This is by far the best explanation I have seen! Thank you!
@redward4383
@redward4383 3 года назад
Thank you so much, i had this kind of issue,but wasn't aware that these relationships actually exist, you've explained it very well.
@susanjoshi5948
@susanjoshi5948 4 года назад
I wish real life relationships were this simple. :D Lit tutorial.
@prianasaputra7583
@prianasaputra7583 Год назад
Thanks, Now I understand this topic. Thank you sho much.
@kmaphane
@kmaphane 11 месяцев назад
Best explanation I found. Thanks a mill
@georgenikou
@georgenikou 4 года назад
Really well explained, thank you very much for this!
@VadimBesedin
@VadimBesedin 3 года назад
As always - great explanation with examples. Thank you
@Hiltaku
@Hiltaku 3 года назад
Thanks! Love the example. Makes the concept very easy to understand
@linaktashifteam1826
@linaktashifteam1826 5 лет назад
very clear explication, thanks
@Egadirov
@Egadirov 5 лет назад
Great example, thanks!
@eli-thegreatdiscovery
@eli-thegreatdiscovery 2 месяца назад
Great video.
@opentech5972
@opentech5972 5 лет назад
That mechanical keyboard sound, satisfying.
@ashique12009
@ashique12009 2 года назад
Nicely explained. So if we have 3 tables like posts, products and images then we can make polymorphic relationship to bring data in optimized way. This can be done if we create two photo tables one is for post_photos and another is product_photos but for polymorphic relation we can reduce one table here. Thanks.
@andywong2244
@andywong2244 Год назад
well said brother!
@adnanasad4674
@adnanasad4674 3 месяца назад
Thanks, I have one question how will we reserve it means Photo::get() and It should fetch relationship data from relevant table example post or product.
@anissmarrouch282
@anissmarrouch282 4 года назад
i was confused on this i am doing it in rails its different code wise but im assuming its the same concept thank you for the video and for the excellent explanation
@asatbekxalimjonov4005
@asatbekxalimjonov4005 3 года назад
amazing
@avfoxstudios3226
@avfoxstudios3226 Год назад
well explained...bravo
@nahueljj
@nahueljj 3 года назад
how to update? i have Polymorphic tags, and i can store success but i cant update fine, the result contact the tags,for example #hello #word and i add , #one.. the result in my input is #hello #word #one #hello #word #one my code.. $tags_name = explode(' , ' , $request->tags_name); foreach($tags_name as $tag_name) { $post->tags()->attach(Tag::updateOrCreate(['name'=>$tag_name])); }
@PovilasKorop
@PovilasKorop 3 года назад
What is the error that you're getting? Maybe you shouldn't to ->attach() but instead create things manually, like PostTag::create('taggable_id' => $post_id) ... etc? (not sure what your polymorphic model is called, assumg PostTag)
@nahueljj
@nahueljj 3 года назад
Hi, thx for the answer, My problem is that I don't think I'm using the most optimal solution to update the registry, since I'm removing the tags with dettach and then adding them again ... es.stackoverflow.com/questions/418957/como-hacer-un-update-en-una-tabla-polimorfica,
@PovilasKorop
@PovilasKorop 3 года назад
@@nahueljj I think it's fine.
@rahweekhum9931
@rahweekhum9931 5 лет назад
Thank you for your useful video.
@dedecovasco
@dedecovasco 4 года назад
Awesome!! Thank you very much
@md.rakibuddinrana3765
@md.rakibuddinrana3765 2 года назад
Awesome🥰 thank you
@MohamedTrabelsi-g8p
@MohamedTrabelsi-g8p 15 дней назад
Great explanation From 2024
@VadimBesedin
@VadimBesedin 3 года назад
But if my Models should have only one photo per record, having regular BelongsTo would be totally enough. Am I right? Posts ---id ---text ---image_id Users ---id ---name ---image_id Images ---id ---filename Or there are still advantages to use Polymorphic Relations in this case?
@PovilasKorop
@PovilasKorop 3 года назад
If you have only those models strictly, then yes, your structure is good. But if in the future you're planning to have, for example, Comments with image_id or something else with image_id, polymorphic structure would allow you to achieve those new fields without changing any structure of DB cause you would reuse the same images database table.
@windigo000
@windigo000 3 года назад
cool. 👍 i just can't bring myself to liking this aproach. one-too-many sleepless nights with slow db without keys. :) but it might have it's uses.
@topalidinka
@topalidinka 3 года назад
Thank you :)
@user-wf5jv1me2b
@user-wf5jv1me2b 3 года назад
!!!!! Thank you very match !
@shubhamsahuSD
@shubhamsahuSD 8 месяцев назад
Got it
@WaheedSindhani
@WaheedSindhani 4 года назад
How do we retrieve all data with relations.
@twentxx
@twentxx 2 года назад
Thanks very much, but this video not include Factories and Seeders
@slablife
@slablife 5 лет назад
Excellent video… you just saved my butt! Do you have any Udemy courses?
@PovilasKorop
@PovilasKorop 5 лет назад
Thanks Mike. Not on udemy, but on teachable - see laraveldaily.teachable.com
@unomas9686
@unomas9686 3 года назад
You are the best teacher ! From russia. putin-juilo
@NMND.
@NMND. 2 года назад
AAAARGH SO BRIGHT! x_x
@vitaminabe
@vitaminabe 3 года назад
thank you, very informative!
@SalmanMemon_Sam
@SalmanMemon_Sam 4 года назад
best
Далее
Laravel: BelongsTo vs Polymorphic? Let's Test!
14:09
Просмотров 26 тыс.
Faster Eloquent: Avoid Accessors with Foreach
9:35
Просмотров 53 тыс.
Девочки, у вас тоже так? 💅🏻✨
00:17
Новый фонарик в iPhone с iOS 18
00:49
Просмотров 566 тыс.
Laravel Pivot Tables: Simple to Advanced Many-to-Many
12:24
Eloquent Performance: TOP 3 Mistakes Developers Make
7:59
Laravel: Create Public API with Cache and Rate Limits
12:18
Laravel Migrations: 12 Useful Tips in 12 Minutes
12:06
Laravel Eloquent: Deeper Relationships with One Query
10:37
Laravel: Change Two Symbols to Boost Eloquent Speed
6:34
Laravel Security: Top 7 Mistakes Developers Make
11:16
Optimizing Eloquent: Running Out Of Memory?
6:11
Просмотров 42 тыс.
Eloquent or Query Builder: When to Use Which?
5:48
Просмотров 87 тыс.
Девочки, у вас тоже так? 💅🏻✨
00:17