Laravel: BelongsTo vs Polymorphic? Let's Test!

  Рет қаралды 26,689

Laravel Daily

Laravel Daily

Күн бұрын

Пікірлер: 33
@Atiradeonvideo
@Atiradeonvideo 2 жыл бұрын
Always really good when a video is reflecting a day-to-day kind of situation at work. These decision (database structure, coding style) are happening a lot under the hood and a good developer should always address all these long-term considerations as you do here. Nice job!
@ejaadhulab8924
@ejaadhulab8924 2 жыл бұрын
this is exactly what I am looking for. Thank you very much for sharing daily tips. Although the tutorial is old the content is not outdated.
@3mro_coding
@3mro_coding 3 жыл бұрын
This review video didn't get what it deserves. Am sharing this to all social networks this really quality content. Thanks for sharing.
@ashrafuzzamashraf8854
@ashrafuzzamashraf8854 Жыл бұрын
Good benchmark video. Thanks
@maiconmva
@maiconmva 4 жыл бұрын
but if you add a index key in class name column, will be much faster
@leonardoldr
@leonardoldr 3 жыл бұрын
I know it's an old video, but in fact for an application that have to be maintained for a long time polymorphic seems to add the inconvenience of "guessing". Pretty much any developer knows what a foreign key is, but maybe just the advanced will realize the polymorphic. Also, would be fine to have a real-world test with the "real" database modelling with 3 tables vs 1 poly and each of them with millions of rows. But, as always very helpful, your videos are helping me a lot! :)
@maxralph01
@maxralph01 2 жыл бұрын
Very informative!
@Construction-agencyCoUk
@Construction-agencyCoUk 4 жыл бұрын
fantastic video - thanks 🙏
@helluci6449
@helluci6449 Жыл бұрын
6:30 also breaks the SOLID principles, right? Is there a way to prevent that?
@ahmedabdnaser1582
@ahmedabdnaser1582 3 жыл бұрын
thank you, this video is very informative. keep going
@shire7949
@shire7949 3 жыл бұрын
Very valuable information
@Jossnaz
@Jossnaz 3 жыл бұрын
I appreciate your videos. I keep thinking as well that you focus a bit too much about "shorter syntax". Just because you can mke it shorter, doesnt mean you should. Readability is king, reading the couple ifs vs that string replace? For me ifs way easier to read. As well imagine you need translations. Your ide will help you find the references. And its easy to add another if. For example i dont like laravel resources a lot either because i like to be able to search for a problematic http call in my code. If you use resource you wont find it any more. Its shorter, but at what cost?
@sonant_bwolfe
@sonant_bwolfe 4 жыл бұрын
"This table full of strings is bigger than this table full of integers, I'm not sure why when I export both as utf8 text they're the same size" :D
@cxian
@cxian Жыл бұрын
What do you call on that Laravel developer console on the bottom of the page? Is that part of the Quick Panel?
@LaravelDaily
@LaravelDaily Жыл бұрын
composer require barryvdh/laravel-debugbar
@cxian
@cxian Жыл бұрын
@@LaravelDaily Thank you sir!
@thatsenam9183
@thatsenam9183 4 жыл бұрын
Really Helpful
@bunwong9718
@bunwong9718 4 жыл бұрын
What is the name of the DEVTOOL bar under the browser?
@PovilasKorop
@PovilasKorop 4 жыл бұрын
Laravel Debugbar github.com/barryvdh/laravel-debugbar
@dusanjovanovski8752
@dusanjovanovski8752 Жыл бұрын
Its a package for debug
@evilwizard7931
@evilwizard7931 2 жыл бұрын
Does having multiple foreign key fields in this case break normalisation? I mean how can the database enforce that only 1 of the fields is populated & the other 2 are null? Also, A big thanks you for your tips & knowledge sharing
@LaravelDaily
@LaravelDaily 2 жыл бұрын
From what I understand, yes, polymorphic relationship breaks the normalization. But normalization isn't a sacred rule, in my opinion.
@evilwizard7931
@evilwizard7931 2 жыл бұрын
@@LaravelDaily I meant the other way, the database can enforce the relationship with the other tables, but how can the table containing multiple foreign key fields as primary relation. What is stopping a record being linked to all 3 other tables is what I'm asking I guess & has no bearing on Laravel/Eloquent. It's as sacred as SOLID, something to strive for, but don't break your back doing it, even the fundamental laws of the universe do it the easy/lazy way :)
@LaravelDaily
@LaravelDaily 2 жыл бұрын
Well, polymorphic relationship is NOT the database relationship, it doesn't have foreign keys or other DB level constraints. If you go for polymorphic, you kinda forget DB constraints and rely on Laravel functionality.
@nabeelyousafpasha
@nabeelyousafpasha 4 жыл бұрын
Do you feel it unnecessary to query multiple times via WITH method rather than JOIN? However some may find join slower but we can manipulate data at db level in a single query using multiple tables with JOIN. DB transactions cost lesser (if i am right). What are your suggestions regarding this
@PovilasKorop
@PovilasKorop 4 жыл бұрын
It's a personal preference, I tend to use all Eloquent possibilities and not Query Builder with join(), whenever possible. Doing it directly with join() sometimes may be quicker, sometimes not. It depends on the situation.
@devmaster8923
@devmaster8923 4 жыл бұрын
how to install the bar like yours? where you can see the result?
@PovilasKorop
@PovilasKorop 4 жыл бұрын
It's called Laravel Debugbar, Google how to install it
@iordanistsapanidis4021
@iordanistsapanidis4021 4 жыл бұрын
Why not use db queries?? easier with() than join() but faster
@pola587
@pola587 4 жыл бұрын
Not recommended for readability
@iordanistsapanidis4021
@iordanistsapanidis4021 4 жыл бұрын
@@pola587 what can't you understand exactly??
@TheBaltLT
@TheBaltLT 11 ай бұрын
what value your talking head adds to this tutorial apart distraction?
@wayne_xyz
@wayne_xyz 11 ай бұрын
So that you can see and remember the actual human being who is making efforts to teach everyone who needs teaching. You ungrateful asshole
Eloquent Polymorphic Relations: Properly Explained
9:56
Laravel Daily
Рет қаралды 41 М.
Laravel Eloquent: Deeper Relationships with One Query
10:37
Laravel Daily
Рет қаралды 144 М.
Deadpool family by Tsuriki Show
00:12
Tsuriki Show
Рет қаралды 7 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 55 МЛН
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
Optimizing Eloquent: Running Out Of Memory?
6:11
Laravel Daily
Рет қаралды 43 М.
4 Tips for Dev Productivity (I've tried many techniques...)
9:01
Laravel Daily
Рет қаралды 2,4 М.
Eloquent: Query 3-Level Relations with hasManyThrough and withCount
7:36
Exceptions in Laravel: Why/How to Use and Create Your Own
12:18
Laravel Daily
Рет қаралды 88 М.
Kafka in 100 Seconds
2:35
Fireship
Рет қаралды 963 М.
Junior Code Review: Laravel Routes, Middleware, Validation and more
19:57
Laravel Pivot Tables: Simple to Advanced Many-to-Many
12:24
Laravel Daily
Рет қаралды 121 М.