Laravel Package for HasManyMerged Relationship

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys in this video I want to show you one laral package eloquent package which is probably less known because it's for quite rare use case but when you need it it would be a massive help called laral has many merged which is for the case that you have has many relationship to two records and you need both at once here's an example from the official readme when you have messages in the model for example model user the user has sent messages and received messages and both are has many relationships to the same message model just with different fields so what that package allows you to do is to have combined messages with two columns as array and I found this package used in an open source project genealogy which we've been covering on this channel for quite a while for quite a few videos I keep finding various gems and Topics in this project so here's how it is used in here in the composer we have has many merged here and here we have a model called person for people basically and we have has many merged and has many merged relation here and this is how it is used in the relationships so people have children every person may have many children but with different Columns of Father ID and mother ID this is the structure of the database of this project also there's a relationship children with children so two levels deep also there are couples so has many emerged from person one ID and person 2 ID there's a separate model of couple and then it allows to use the relationship for example this is used inside of the same model Counting the children of the person and Counting the couples of that person so you can use this as a has manual relationship so yeah this is just a small quick Showcase of the code and the package what do you think would you have cases for such relationship or would you prefer building your own custom functions to achieve the same things let's discuss in the comments and if you want to dive deeper into how eloquent works with relationships and other functionality I have a separate course called eloquent expert level recently updated to larel 11 so totally recommend you to go through that and I will link that in the description below that's it for this time and see you guys in other videos
Info
Channel: Laravel Daily
Views: 2,658
Rating: undefined out of 5
Keywords:
Id: dknnj4SryjE
Channel Id: undefined
Length: 2min 18sec (138 seconds)
Published: Tue Apr 30 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.