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.
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 =)
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.
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?
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
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.
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
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.
exactly, it slowed it down but it did simplify the work, so if you're application doesn't require or need the small performance difference, it's a good choice though.
@ 8:00 you are showing off the functionality of `hasManyDeep` to associate employees with their countries. Could this also be achieved with an additional `hasManyThrough` definition? Where it is defined as `hasManyThrough(Employee::class, Shop::class)` ? Or do those methods not chain well / is this strictly better for performance?
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
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?
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.
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!
thank you so much Sir, i just have a question, you know when we use the 'with' function with a model? it generates two queries, one for the model and one for the relation, can i instruct Laravel to do left join to fetch the data with one query? i don't want to use the query builder too. thanks again for all of your work.
how to get all data of that relationships not through some. ex all countries, and all cities and all shop in 1 query, i wanna make tree.. pls advice sir
Bro, if possible all your future video please make very big fonts and alsp zoom abit because when we use phone its hard to see. It cause not complete watch
How to do belongstothrough on same model Like Posts belongs to User & User Belongs To Manager ( Same User model). How Do i Get Manager From Post Without $post->user->manager ?
@Laravel Daily Sveikas Povilai, niekaip negaliu issaikinti turiu panasia problema: character->quests->objectives->tasks turiu padaryti toki dalyka paspaudus mygtuka "track quest" uzsitrakina questas kaip betkokiam zaidime sone atsiranda lentele kad zaidejas matytu questa kuri trackina. man reiketu duomenu is visus modeliu quest, objectives, tasks kurios pajungsiu ant laravel websockets kad kai zaidejas progresuoja per savo questa jie butu automatiskai updatinami. klausimas butu toks: ar tai butu imanoma padaryti su hasMany ar hasManyThrough ar belongsToMany niekaip negaliu isspresti sitos bedos reikia uzloadinti questus su objectives ir tasks
Žinok trumpame komentare negaliu atsakyti, reikia žaistis ir eksperimentuoti, deja nebeturiu laiko tokiam individualiam konsultavimui. Bandyk rašyti į Laracasts forumą.
Please help I am new to relationship in laravel I have category table , subcategory table it contains category_id , products table it contains user_id, category_id , subcategory_id and title... Please make the relationship for this i will be helpfull
You don't need to. You can have only one table with categories like so: id; name; parent_id; ... other columns. parent_id to be null by default. Hope you'll get the ideea
This will soon be the one of the most viewed video in this channel 😂 good work
Correct 😂
Yes I think ❤
Yup
Yes, it's me in 8 month, revisiting this video 😂
I cannot thank you enough! Your channel is AMAZING! Thank you for doing what you do!
This packages should be in the framework. They're really good.
Anyone can add anything to the framework, it's open-source, so you can try.
Ι was about to say the same.
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.
This is EXACTLY what I needed to see. Thank you so much!
Superb Laravel specialized developer of all the time. I like you Sir
Большое спасибо) смотрю каждый день. Всегда очень полезно
Реал, не сложно говорит. Прекрасно понятно
Иногда такие вещи показывает что удивляешся
Dude! you are awesome, so so accurate!
You are a good teacher! I love your channel!
Great work!
You just earned a new subscriber. Kudos to you. You just showed me exactly what I needed to see
that is what i was searchingfor an hour, thanks alot sir !!!
finally the addon is mature enough to use! nice tutorial.
Life saving tip. Life saving package. Congrats to both.
you are the best ,thanks you for improving my laravel knowledge, i was do stupid things before i see this video 😅
by this video you can understand the principle of has_many and belongs_to in other languages and frameworks also
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 =)
Many thanks You are best in yours job ... I cannot thank you enough! Thank you teacher for your trainings!
Thanks for your laravel daily tips.
Problem solving, thanks sir!
First time seeing video on youtube without dislike button being tick.
You are the best, Povilas!
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.
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?
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
Really helpful video. Thank you
Your videos are always wonderful.
I literally needed to know this, thank you so much 💓 keep up the great work 💪
This is what I need!!! Thankyou so muchh for this
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.
Yes, for complex queries raw queries are still the best.
Excellent explanation 🎉
Your tutorials help a lot... Thanks
Очень крутое видео, спасибо за улучшение наших знаний в Laravel:)
ну я хз понял ли он)
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
Up
Feel you bro, done the same: usign foreign keys to those deep deep relationships
Amazing content. It helps me a lot. Thanks
Thank you.. this help me a lot..
OMG, this is amazing thank you so much!
composer require staudenmeir/belongs-to-through:"^2.5"
not installing on laravel 8
Really good job. Thanks 🙏
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.
awesome, thanks you, please more and more advanced eloquent
I have a full course about advanced eloquent: laraveldaily.teachable.com/p/laravel-eloquent-expert-level
Thank you so much. It's help me a lot.💝💝
The BelongsToThrough query actually became less efficient, no? It reduced the queries and models used but memory and time to execute increased.
exactly, it slowed it down but it did simplify the work, so if you're application doesn't require or need the small performance difference, it's a good choice though.
you always provide good content
This is really great. Love it
This is awesome bro......It will help me a lot :)
very very very helpful package thanks !
Wow! that`s really really awesome!
Could you make one video of belongstomany with three level deep query with where condition (with the last one)?
Thank sir , one of the best video
@ 8:00 you are showing off the functionality of `hasManyDeep` to associate employees with their countries. Could this also be achieved with an additional `hasManyThrough` definition? Where it is defined as `hasManyThrough(Employee::class, Shop::class)` ? Or do those methods not chain well / is this strictly better for performance?
🎉 save the day, thanks a lot
Awesome! Thanks
You are awesome 😍
You are a god to me, thank you so so much
This is all nice but the same thing can be achieved with php arrays if you know how.
Hi, I watched your video about function's return type, is there any documentation about the full list of return types? Thank you!
Any PHP variable type or PHP/Laravel class could be a return type. There's no list.
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)
Retweet feature will be nice
@@ikarahubs965 nested comment please
really helped me with retrieving data, but what about insert data? is it possible to do so?
Thanks for this how can i learn more about eager loading
thank you very much for tutorial sir!!
Awesome!
What about A -> many to many -> B belongs to -> X, is possible using this package to access X from model A ?
Very informative video, thanks.
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
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
very well. thank you.
this help me a lot, thanks
Thx for the great content
what ide setup you use ? It looks so good and to the point
Phpstorm default
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?
This is cool!!!
You do not show how to set search filter with "with" relation and its deep level with multiple column. Can you do that?
Muchas gracias 🤯
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.
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!
It will work the same, the only thing you will have to do is overwrite the connection variable inside of the model.
how can we select only some attributes of the second table?
what package did you used to showing relation and through text in the model?
good work!!!
thank you so much Sir, i just have a question, you know when we use the 'with' function with a model? it generates two queries, one for the model and one for the relation, can i instruct Laravel to do left join to fetch the data with one query? i don't want to use the query builder too.
thanks again for all of your work.
No, it's either query builder with join and one query, or eloquent model with eager loading and two queries.
@@LaravelDaily okay, thanks a lot
Great video💙
how to get all data of that relationships not through some. ex all countries, and all cities and all shop in 1 query, i wanna make tree.. pls advice sir
Bro, if possible all your future video please make very big fonts and alsp zoom abit because when we use phone its hard to see. It cause not complete watch
Pretty helpful!
Good job!
Thank you!
how to get limited relationship data with using laravel and mongo db please give me solution thank you
Very helpful video.
Why laravel framework does not have these kind of relationships yet?
You're free to submit pull requests to the framework and add it.
Great, now I just need to know how to access deeper relationships with a girl
To talk with her dad or grandad?
You would be fine with just BelongsTo
How to do belongstothrough on same model Like Posts belongs to User & User Belongs To Manager ( Same User model). How Do i Get Manager From Post Without $post->user->manager ?
how to query with scope to show id 1 from shop ?
6:03 the query count went down but the time & memory usage went up, less performant 🤔maybe it is not using an index
Thank you
But I can do this queries using facade querys
@Laravel Daily
Sveikas Povilai,
niekaip negaliu issaikinti turiu panasia problema:
character->quests->objectives->tasks
turiu padaryti toki dalyka paspaudus mygtuka "track quest" uzsitrakina questas kaip betkokiam zaidime sone atsiranda lentele kad zaidejas matytu questa kuri trackina.
man reiketu duomenu is visus modeliu quest, objectives, tasks kurios pajungsiu ant laravel websockets kad kai zaidejas progresuoja per savo questa jie butu automatiskai updatinami.
klausimas butu toks: ar tai butu imanoma padaryti su hasMany ar hasManyThrough ar belongsToMany niekaip negaliu isspresti sitos bedos reikia uzloadinti questus su objectives ir tasks
Žinok trumpame komentare negaliu atsakyti, reikia žaistis ir eksperimentuoti, deja nebeturiu laiko tokiam individualiam konsultavimui. Bandyk rašyti į Laracasts forumą.
Thanks
Please help
I am new to relationship in laravel
I have category table , subcategory table it contains category_id , products table it contains user_id, category_id , subcategory_id and title... Please make the relationship for this i will be helpfull
You don't need to. You can have only one table with categories like so: id; name; parent_id; ... other columns. parent_id to be null by default. Hope you'll get the ideea
Please make a video about this package belongstothrough
That package has a very good documentation, not sure why the video is needed
very helpfull
thanks
Best video. 👌
Brilliant!
Lovely!
What about belongsToManyThrough ??