Laravel Eloquent: Deeper Relationships with One Query

  Рет қаралды 134,480

Laravel Daily

Laravel Daily

Күн бұрын

If you work with a project that has multiple levels of hasMany relationships, you can use hasManyThrough instead, or one of a few packages I will show in this video.
Official docs on HasManyThrough: laravel.com/docs/8.x/eloquent...
Packages by Jonas Staudenmeir: github.com/staudenmeir
My course "Eloquent: Expert Level": laraveldaily.com/course/eloqu...
My course "Better Eloquent Performance": laraveldaily.com/course/eloqu...
- - - - -
Support the channel by checking out my products:
- My Laravel courses: laraveldaily.com/courses?mtm_...
- Laravel QuickAdminPanel: quickadminpanel.com
- Livewire Kit Components: livewirekit.com
- - - - -
Other places to follow:
- My weekly Laravel newsletter: us11.campaign-archive.com/hom...
- My personal Twitter: / povilaskorop

Пікірлер: 179
@chengkangzai
@chengkangzai 2 жыл бұрын
This will soon be the one of the most viewed video in this channel 😂 good work
@muditgulgulia5350
@muditgulgulia5350 2 жыл бұрын
Correct 😂
@aboodlibda7161
@aboodlibda7161 2 жыл бұрын
Yes I think ❤
@dibbyo456
@dibbyo456 2 жыл бұрын
Yup
@chengkangzai
@chengkangzai 2 жыл бұрын
Yes, it's me in 8 month, revisiting this video 😂
@0x0456
@0x0456 Жыл бұрын
This is EXACTLY what I needed to see. Thank you so much!
@pankajbokdia
@pankajbokdia 2 жыл бұрын
I cannot thank you enough! Your channel is AMAZING! Thank you for doing what you do!
@DennisBraga
@DennisBraga 2 жыл бұрын
Life saving tip. Life saving package. Congrats to both.
@salman-804
@salman-804 2 жыл бұрын
I learnt a lot from this tutorial. Thanks a lot !!
@worthsalive
@worthsalive Жыл бұрын
You just earned a new subscriber. Kudos to you. You just showed me exactly what I needed to see
@MahmodurRahmanShihab
@MahmodurRahmanShihab 2 жыл бұрын
Thanks for your laravel daily tips.
@hamzaradouan4074
@hamzaradouan4074 2 жыл бұрын
I literally needed to know this, thank you so much 💓 keep up the great work 💪
@philipcook6191
@philipcook6191 Жыл бұрын
Soon to by membership this month. Your way of explaining wastes no time and you to the point and so knowledgeable, been watching for year but I need to get into your full courses. Thanks for this, a super help. From cape town, south africa.
@jeanfrancois3605
@jeanfrancois3605 2 жыл бұрын
OMG, this is amazing thank you so much!
@KasimSheyi
@KasimSheyi 2 жыл бұрын
Your videos are always wonderful.
@shaadishtiaque2084
@shaadishtiaque2084 2 жыл бұрын
Your tutorials help a lot... Thanks
@AldhiAlbadri
@AldhiAlbadri 2 жыл бұрын
Problem solving, thanks sir!
@bilaljan7659
@bilaljan7659 Жыл бұрын
that is what i was searchingfor an hour, thanks alot sir !!!
@ValeriyaPolovinkina
@ValeriyaPolovinkina 2 жыл бұрын
Thank you for this video. In real life we need in one query some fields from first level, some from second level, third, etc. But it is another story =)
@glowiever
@glowiever 2 жыл бұрын
finally the addon is mature enough to use! nice tutorial.
@tiagooliveira14
@tiagooliveira14 2 жыл бұрын
This packages should be in the framework. They're really good.
@LaravelDaily
@LaravelDaily 2 жыл бұрын
Anyone can add anything to the framework, it's open-source, so you can try.
@KgfLikia
@KgfLikia 2 жыл бұрын
Ι was about to say the same.
@levieraf
@levieraf 2 жыл бұрын
Dude! you are awesome, so so accurate! You are a good teacher! I love your channel! Great work!
@azeroth5672
@azeroth5672 2 жыл бұрын
This is what I need!!! Thankyou so muchh for this
@vigneswarans13
@vigneswarans13 3 ай бұрын
Excellent explanation 🎉
@msdeav
@msdeav 2 жыл бұрын
Really helpful video. Thank you
@user-rm4zo1mg5o
@user-rm4zo1mg5o 2 жыл бұрын
Something done with few lines I have to do with complex sql queries with joins, to do the same on old projects running over laravel 5.2 in my main work. Thank for this video.
@HadiHasanpur
@HadiHasanpur 11 ай бұрын
Many thanks You are best in yours job ... I cannot thank you enough! Thank you teacher for your trainings!
@md.robelahammed4763
@md.robelahammed4763 Жыл бұрын
Amazing content. It helps me a lot. Thanks
@vbadheli
@vbadheli 2 жыл бұрын
Thank you.. this help me a lot..
@JamesShisiah
@JamesShisiah 2 жыл бұрын
This is really great. Love it
@auroraapps1853
@auroraapps1853 Жыл бұрын
Superb Laravel specialized developer of all the time. I like you Sir
@biplobshaha2829
@biplobshaha2829 Жыл бұрын
Thank you so much. It's help me a lot.💝💝
@user-zg1pc6md6y
@user-zg1pc6md6y 2 жыл бұрын
Большое спасибо) смотрю каждый день. Всегда очень полезно
@user-ld1gz1cr1j
@user-ld1gz1cr1j 2 жыл бұрын
Реал, не сложно говорит. Прекрасно понятно
@ARMONEY666
@ARMONEY666 2 жыл бұрын
Иногда такие вещи показывает что удивляешся
@shahosanandaji9894
@shahosanandaji9894 9 ай бұрын
You are the best, Povilas!
@MUJAHIDKHAN
@MUJAHIDKHAN 2 жыл бұрын
Thank sir , one of the best video
@aryarizkysandi8351
@aryarizkysandi8351 2 жыл бұрын
thank you very much for tutorial sir!!
@alexandergontsov6219
@alexandergontsov6219 Жыл бұрын
Really good job. Thanks 🙏
@poplach
@poplach 2 жыл бұрын
Very informative video, thanks.
@claudiomenares4172
@claudiomenares4172 2 ай бұрын
Muchas gracias 🤯
@hostname47
@hostname47 2 жыл бұрын
very very very helpful package thanks !
@amrqawasmeh
@amrqawasmeh Жыл бұрын
Thx for the great content
@Trizen321
@Trizen321 2 жыл бұрын
you always provide good content
@newtonsefa5721
@newtonsefa5721 8 ай бұрын
Thank you
@abdalkhalekchamkha3622
@abdalkhalekchamkha3622 Жыл бұрын
you are the best ,thanks you for improving my laravel knowledge, i was do stupid things before i see this video 😅
@tarekalhalabi8776
@tarekalhalabi8776 2 жыл бұрын
Great video💙
@Dinookys
@Dinookys Жыл бұрын
🎉 save the day, thanks a lot
@codepilot2766
@codepilot2766 2 жыл бұрын
This is awesome bro......It will help me a lot :)
@QianZhiwei
@QianZhiwei Жыл бұрын
very well. thank you.
@Matheus708
@Matheus708 Жыл бұрын
Wow! that`s really really awesome!
@g3n1kindra
@g3n1kindra 2 жыл бұрын
this help me a lot, thanks
@YT-Gmailer
@YT-Gmailer 2 жыл бұрын
Thank you!
@amgadalwattar2863
@amgadalwattar2863 2 жыл бұрын
very helpfull thanks
@programadorweb8403
@programadorweb8403 Жыл бұрын
good work!!!
@cethartest469
@cethartest469 2 жыл бұрын
awesome, thanks you, please more and more advanced eloquent
@LaravelDaily
@LaravelDaily 2 жыл бұрын
I have a full course about advanced eloquent: laraveldaily.teachable.com/p/laravel-eloquent-expert-level
@my_religion
@my_religion 2 жыл бұрын
Pretty helpful!
@rdvr
@rdvr 2 жыл бұрын
Brilliant!
@nbqenglishvietsubstyle117
@nbqenglishvietsubstyle117 2 жыл бұрын
You are a god to me, thank you so so much
@ahmedsyam
@ahmedsyam 2 жыл бұрын
Good job!
@bmtamim7818
@bmtamim7818 2 жыл бұрын
You are awesome 😍
@rishabhandari2501
@rishabhandari2501 2 жыл бұрын
Helpful 🙌🖤
@erh4rdt
@erh4rdt 2 жыл бұрын
great, thank you!
@devsun9063
@devsun9063 2 жыл бұрын
Thanks 🙏
@mostafamahfouz1139
@mostafamahfouz1139 2 жыл бұрын
thanks a lot
@demeja16
@demeja16 2 жыл бұрын
Очень крутое видео, спасибо за улучшение наших знаний в Laravel:)
@maxgoose4671
@maxgoose4671 2 жыл бұрын
ну я хз понял ли он)
@ekselyum34
@ekselyum34 2 жыл бұрын
Thanks 👏
@RANJEETKUMAR-wz4dg
@RANJEETKUMAR-wz4dg 2 жыл бұрын
amazing thanks
@achmadimanfirmansyah663
@achmadimanfirmansyah663 2 жыл бұрын
thank you
@AlexTheGreatish
@AlexTheGreatish 2 жыл бұрын
This is great thank you.. Could you do a video explaining the different type of relationships and how the database structures should be set up in terms of where foreign keys are, etc?
@LaravelDaily
@LaravelDaily 2 жыл бұрын
I have an article: blog.quickadminpanel.com/eloquent-relationships-the-ultimate-guide/ Also, it's best to read the docs: laravel.com/docs/8.x/eloquent-relationships
@Raftor74
@Raftor74 2 жыл бұрын
Awesome!
@mehedihasansagor599
@mehedihasansagor599 2 жыл бұрын
thank you very much
@berthojoris
@berthojoris 2 жыл бұрын
The best....Thanks
@ChangeYourLifeForever
@ChangeYourLifeForever 2 жыл бұрын
by this video you can understand the principle of has_many and belongs_to in other languages and frameworks also
@GergelyCsermely
@GergelyCsermely 2 жыл бұрын
Thanks
@GabrielMoura32
@GabrielMoura32 2 жыл бұрын
thanks
@muditgulgulia5350
@muditgulgulia5350 2 жыл бұрын
Best video. 👌
@chibuikeumezinwa7827
@chibuikeumezinwa7827 2 жыл бұрын
Lovely!
@huynguyenduyit4441
@huynguyenduyit4441 Жыл бұрын
Amazing
@fuhfaysal
@fuhfaysal Жыл бұрын
awesome!!
@josuebarros5727
@josuebarros5727 2 жыл бұрын
This is cool!!!
@aineelzihnee9634
@aineelzihnee9634 2 жыл бұрын
First time seeing video on youtube without dislike button being tick.
@arashpirhadi1326
@arashpirhadi1326 2 жыл бұрын
great video thanks. :) but i think in some situation like this performance will drop after 2 joins and more. I mostly using DB facade for retrieving data from database.
@LaravelDaily
@LaravelDaily 2 жыл бұрын
Yes, for complex queries raw queries are still the best.
@shofada
@shofada 2 жыл бұрын
Thanks or putting this together. If you had a page that needs to display say for every employee, the country, city and shop, what might the query look like?
@martinh4982
@martinh4982 2 жыл бұрын
Hi Povilas, In Eloquent is it possible to join to an arbitrary sql statement? For example, say I have a User model and I want to create a UserStats relationship. However UserStats is not a table, but a sql statement that computes stuff like last_login, number_of_posts, up_votes etc. The only way I've found to do this so far is with a database view that I manage with migrations, but was wondering if this could be done purely in Laravel.
@AbdulMajeedShehzad
@AbdulMajeedShehzad 2 жыл бұрын
Thank you for the great video, I've a question for this scenario. is it a good practice to use keys in deep relations ? for example in employees table we add country_id to avoid complex queries when working on reporting. I've been looking for this answer for quite a long time
@kauandouglas
@kauandouglas 2 жыл бұрын
Up
@javieru5871
@javieru5871 2 жыл бұрын
Feel you bro, done the same: usign foreign keys to those deep deep relationships
@ugayashan8659
@ugayashan8659 2 жыл бұрын
Great content, can you make a video on user referral system using laravel Eloquent
@jimishukurow2286
@jimishukurow2286 2 жыл бұрын
royal like from me!
@akintandavid2500
@akintandavid2500 11 ай бұрын
Thanks for this how can i learn more about eager loading
@TechITWorld
@TechITWorld 2 жыл бұрын
Could you make one video of belongstomany with three level deep query with where condition (with the last one)?
@ilyasabdut
@ilyasabdut 2 жыл бұрын
what package did you used to showing relation and through text in the model?
@taghreedomer6208
@taghreedomer6208 Жыл бұрын
really helped me with retrieving data, but what about insert data? is it possible to do so?
@dApoTB
@dApoTB 2 жыл бұрын
Thanks for your videos! Could you please do one about constructing relationships between tables that are in different databases and connection names to those tables cannot be hard coded. E.g.: User table is in DB1, Post table is in DB2 and Comment table is in DB3. Can we construct a relationship here? Thanks!
@SonsParaRelaxar
@SonsParaRelaxar 2 жыл бұрын
It will work the same, the only thing you will have to do is overwrite the connection variable inside of the model.
@martinjones8231
@martinjones8231 2 жыл бұрын
I follow all of your video u are great because the laravel path am on is just what u can teach so I need ur personal contact.
@yogeshwarbarai9686
@yogeshwarbarai9686 10 ай бұрын
what ide setup you use ? It looks so good and to the point
@LaravelDaily
@LaravelDaily 10 ай бұрын
Phpstorm default
@renwar
@renwar 2 жыл бұрын
Very helpful video. Why laravel framework does not have these kind of relationships yet?
@LaravelDaily
@LaravelDaily 2 жыл бұрын
You're free to submit pull requests to the framework and add it.
@afestacincome2224
@afestacincome2224 2 жыл бұрын
Can you please do a Short video on how to create nested comment and also a Short video on how to retweet a post ( Just like Twitter)
@ikarahubs965
@ikarahubs965 2 жыл бұрын
Retweet feature will be nice
@niffeydovie4906
@niffeydovie4906 2 жыл бұрын
@@ikarahubs965 nested comment please
@anisurrahman6634
@anisurrahman6634 2 жыл бұрын
@Formula7Driver
@Formula7Driver 2 жыл бұрын
What if we want to update data? I have a Sales Order, with Items, and each item has a list of Operation IDs to produce the item
@sir_brian_d
@sir_brian_d 2 жыл бұрын
6:03 the query count went down but the time & memory usage went up, less performant 🤔maybe it is not using an index
@gloriaordiz5924
@gloriaordiz5924 9 ай бұрын
Please make a video about this package belongstothrough
@LaravelDaily
@LaravelDaily 9 ай бұрын
That package has a very good documentation, not sure why the video is needed
@johnerrolprincipe8992
@johnerrolprincipe8992 11 ай бұрын
Hi, I watched your video about function's return type, is there any documentation about the full list of return types? Thank you!
@LaravelDaily
@LaravelDaily 11 ай бұрын
Any PHP variable type or PHP/Laravel class could be a return type. There's no list.
@patihuuu6288
@patihuuu6288 2 жыл бұрын
What about A -> many to many -> B belongs to -> X, is possible using this package to access X from model A ?
@titon9688
@titon9688 2 жыл бұрын
how to query with scope to show id 1 from shop ?
@Ayvengo21
@Ayvengo21 Ай бұрын
All the time i see that orm magic like this I'm asking myself does it worth it or maybe some escaped sql would be way easier to read and write. Because sql knowledge could be transferred between projects while knowledge of specific orm might be problematic.
@NazmulHaqueroton
@NazmulHaqueroton 2 жыл бұрын
Sir, @LaravelDaily If i want to add another table: shop_branches fields: 1) id 2)shop_id 3) shop_branch_name then how i define relationship to access: shop_branch_name
5 tips for supercharged Laravel Eloquent queries
16:29
Andrew Schmelyun
Рет қаралды 67 М.
Laravel: Repository Pattern in practice
27:13
Przemysław Przyłucki
Рет қаралды 10 М.
У мамы в машине все найдется
00:38
Даша Боровик
Рет қаралды 2,2 МЛН
Chips evolution !! 😔😔
00:23
Tibo InShape
Рет қаралды 11 МЛН
Eloquent Polymorphic Many-to-Many: Practical Example
4:58
Laravel Daily
Рет қаралды 10 М.
Laravel: Create Public API with Cache and Rate Limits
12:18
Laravel Daily
Рет қаралды 44 М.
Laravel Eloquent: Order By Relationship - Two Ways
6:01
Laravel Daily
Рет қаралды 29 М.
Introduction To Eloquent | Laravel For Beginners | Learn Laravel
45:20
Faster Eloquent: Avoid Accessors with Foreach
9:35
Laravel Daily
Рет қаралды 51 М.
How good is the latest version of ChatGPT? | BBC News
23:16
BBC News
Рет қаралды 110 М.
Eloquent Polymorphic Relations: Properly Explained
9:56
Laravel Daily
Рет қаралды 39 М.
Eloquent vs Query Builder vs SQL: Performance Test
5:37
Laravel Daily
Рет қаралды 49 М.
Gitlab DELETING Production Databases | Prime Reacts
17:27
ThePrimeTime
Рет қаралды 292 М.
Follow @karina-kola please 🙏🥺
0:21
Andrey Grechka
Рет қаралды 20 МЛН
Un poco de suerte la del sr perro 😮 - Rally Santafesino
0:10
Nanci Torres
Рет қаралды 12 МЛН
Hahaha
0:11
ARGEN
Рет қаралды 4,2 МЛН
I want eating Ice Cream 🤣👻
0:13
Ben Meryem
Рет қаралды 3,1 МЛН