Laravel API Resource: Loading relationship the right way

preview_player
Показать описание

We build our API on Resource Classes, but how can we avoid infinite nested relationship loading? Let's learn to address this by eager loading!

Source code for this lesson:

** Affiliated links
Use the legendary Git GUI for FREE! You are seriously missing out if you are not using it.

Beautiful designs created instantly to wow your social networks!

Outro Music:
Рекомендации по теме
Комментарии
Автор

Not only did this fit a specific use case I was trying to find a workaround for, but it was well presented and easy to follow. You also made an effort to cover the premise on why it should be carried out with the given methods. 10/10!

lidsy
Автор

I have been looking for this for a year. Thank you so much!

yasaryousuf
Автор

Just magic! You blew my mind with this! Thank you for the awesome content!

antonisantoniadis
Автор

Finally I found what I want
Thank You Sir!!! For this Video . Keep it up .

camboshare
Автор

The best. To point short and concise👍🙏

m.faizanshakir
Автор

Great video! I would love more laravel videos. One on laravels resource collections would be awesome. Keep it up!

blaynebennett
Автор

Thank you very much! Brilliant video! Subscribed, looking forward to seeing your channel grow :)

joshsavage
Автор

what is difference between load() and loadMissing() ?
in the example in video what if we use $this->load() instead of $this->loadMissing() ?
plz help

codingcat
Автор

Nice, thanks. Very helpful, keep up the spirit!

azolazubizarreta
Автор

I tried the same thing but without the ->get on the controller it isn’t mapping the data. Whenever I do the above with the ->get it is returning an empty array when I return the resource collection?

jessedeboer
Автор

Great videos, what editor are you using?

ReyLimJr
Автор

Have a question.
On my Category Model I have this parent_id that is being used by `parent(): belongsTo` 'relationship function' that is pointing to the table itself (id). How should I write this self referencing relationship inside the eloquent resource?

jamols
Автор

Pile au moment où j'en cherchais !

kenandiprince
Автор

Error: Call to a member function format() on null

mohamedALI-enic
Автор

4 months ago I watched your video and found it to be very helpful, now I am again watching this because I am working on a project where we had so many resources and all these resources are highly nested...in one API resource at least 4-5 other resources are called and they are also nested with more resources.
So we came into a performance issue problem, APIs are taking a long time to return the response, I was doing some code optimization.
No eager loading is done on these resources. So can you tell me, whether to optimize the response of only one API, I need to eager load all the relationships on the nested resources? Or there is any other solution.

Kindly guide me.

randomguy
Автор

please make a tutorial where we had to do a high level of manipulations in most of the DB keys before sending them to API, using resources, not just dumping all the db columns.

randomguy
Автор

thxs man it helped me but be slowly please i am new in laravel

Blacktube
Автор

where can i find the code on git?
and can you explain how to to this with post like you surgested :)

Toobshub
Автор

How to do this ‘ $users = User::with(['company']);

return ‘ with Post. So how to load user with Company and Post.

tobes
Автор

Good video instead of providing us code sir please slow little bit. Otherwise fine thanks

hilaltube