Today we have a short video that will be devoted to Laravel relationships, namely has many through relationships. Many of you know the relationship hasMany, constantly work with it. But not everyone knows about HasManyThrough relationships, although it is very convenient and sometimes necessary.
Link to the repository from the video - https://github.com/staudenmeir/eloque...
LaravelHasManyThrough # laravel # cutcode
❗️❗️❗️How to make complex sites in laravel? It's easy with cutcode!
Support my project - https://cutcode.ru/
Buy me coffee - buymeacoffee.com/cutcode
🤖🤖🤖My assistant Taylor is ready to give you a present. Pick up here - https://cutcode.ru/chat-bot
-------------------------------------------------- -------------------------------
⏰ Timecodes:
00:00 Introduction
00:51 Studying the official Laravel documentation on has many through
02:13 An example on multilevel links
04:05 Adding HasManyThrough communication
06:25 The advanced package on multilevel relationships has many deep
10:30 A little about optimization
Friends, I welcome everyone to the Cutcode channel! Today we have a short video that will be devoted to Laravel relationships, namely has many through relationships. Many of you know the relationship hasMany, constantly work with it. But not everyone knows about HasManyThrough relationships, although it is very convenient and sometimes necessary. But this video will not only focus on HasManyThrough relationships, but we will also look at a library that extends this relationship and makes it even more interesting. If HasManyThrough jumps over one level of relations for us, then in this library we can work with any hierarchy of levels. Let's start by looking at HasManyThrough with an example of how it works.
If we pay attention to the documentation and the initial example of a table hierarchy, then we immediately see that we have Projects projects, they are connected HasMany with a connection with Enviropments, and Enviropments are connected with Deploiments, and in order for us to get all Deploiments from Projects through Enviropments, in the usual scheme the work would have to go first through all the Enviropments and from them take Deploiments and thereby fill all the Deploiments from Projects. With the HasManyThrough relationship, we can do this directly through the Enviropments modeler. How it will look like we can see here: that is, we use the Eloquent method for the HasManyThrough relationship and indicate what result we want to see, what will be given to us in the end, that is, all Deploiments and through which model through Enviropments. That is, here we must indicate the final model and the model through which we get to Deploiments, and this model must be a link from Projects HasMany.
Let's take a look at a more live example, not from the Laravel documentation.
-------------------------------------------------- -------------------------------
📹 share this video with your friends:
• Laravel отношения HasManyThrough. Многоуро...
🔔 subscribe to the YouTube channel: / @cutcoderu
📼 Laravel course from scratch:
• Курс по Laravel 8 обучение с нуля. Бесплат...
Laravel HasManyThrough relationship. Multilevel communications and eloquent methods in Laravel
-------------------------------------------------- -------------------------------
🔗 our website: https://cutcode.ru/
📷 our instagram: / cutcoderu