The video explains it very well, but I was kinda hoping you would explain how to use many-to-many relation together with seeders, that's the more complicated stuff, at least for me. :) Great explanations as usual! Love your videos.
In what scenario? A pivot table in Laravel can have multiple foreign keys depending on the relationship it represents. It is possible to have a pivot table with 3 foreign keys if the relationship requires it.
Hi Vadim. Thank you so much :) I'm using an extension named Database Client, you can find it right here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-4dId4tpEYII.html
Hi there can you suggest vscode packet for better experience when you write code. Especially; the one about migration file belongsToMany complition at 7.34 is lovely.
It's better to watch the third video from this video series where I setup Visual Studio Code: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-KAUxgUvC514.html
what is the advantages of pivot table in a such case post - caregories? I mean we could create a field like category_id in posts table and we could add a foreign key which references id in the categories table. That what i do usually in my projects. Could you explain why do we need pivot table for category and posts? What are the advantages and disadvantages your way and my way?
If you add the category_id inside the posts table you can't have a many to many relationship. That means you have to duplicate an entire post just to change the category_id inside the posts table. I think you are confused with another relationship!
@@codewithdary oh you are right. My scenario was about one post can belong to only one category. In your scenario, the user can assign multiple category to a post. Got it.
@@siyahkedilucifer but if you have post_id in your category table you can have a one to many relationship. This is simpler but the problem is you end up with repeating category names - bad for storage and performance when it comes to GB category tables