Laravel API Resources: 3 More Complex Examples

preview_player
Показать описание
Eloquent API Resources are typically used to transform API results into the format that you need, but did you know about more complex conditions and relationship structures that you can use in the API Resource class? I will show you 3 open-source examples.

Examples mentioned in the video:

- - - - -
Support the channel by checking out our products:
Рекомендации по теме
Комментарии
Автор

when I see your video. I am feeling like improve to the next level in Laravel ❤

yashpatel
Автор

as far as i understand, resources are a mechanism to represent models, in other words transform model data for json api response, and by doing that we can take away code from controllers and make controllers more clear

JohnToridas
Автор

Useful, no BS, straight to the point👍

chazzman
Автор

Your explanation is very APT and very understanding..

anything_goes
Автор

Yes, I'm using it since I learned from Your course and free Youtube videos. It is really cool. Thanks for this video too,

GergelyCsermely
Автор

I use resources for api response. Btw love your work and dedication on explaining minute details in laravel which most others don't know about.

pintu
Автор

Thank you for this video. On my point, resources very helpfull feature. I use them all time during development application, becouse it helps me keep my code cleanest and clearer. And, of course, resources help me more flexible creating response formats

qcumsny
Автор

I use API resources and it is awesome.

Viveksharmaa
Автор

If returning data with a laravel api takes 637 ms the same size of data in lumen it takes 150 ms . so i prefer to do it with lumen i hope if there could be a way to remove all the extra features from laravel in a api response to increase the speed.

ammarqureshi
Автор

in some case, when we only need to transform some data in one place, we can do without creating another api resource class like this

User::paginate(10)
->through(function ($user) {
return [
'id' => $user->id,
'name' => $user->name,
'email' => $user->email,
'image' => $user->image
];
});

wailantirajoh
Автор

Not much SRP expert, but is it a good idea to delegate the reversion @ 2:23 and other complex things to separate methods?

sirajul-anik
Автор

what`s your thought sir with timcdonald json API resource

genephillip
Автор

I was using this approach today and I found something strange related this topic and response macro (another of your video).
If you use api resource (collection) with pagination and response macro, the pagination data, like links, desappear from the response content. Can you reproduce this bug?

giacomogaravaglia
Автор

Hello Mr.Povilas, I have a minor question if you may...

Is it a good practice to shuffle or reconstruct an array using resources API?
And if no what do you recommend other than some complex algorithms?

mohammadazzam
Автор

I'm looking for solution.. how can we search database on the basis of relationship.. like i have a situation.. a field technology and other is version.. both has different tables and the pivot.. i want to search a technology with specific version if exists in relation

SohailKhan-yyxc
Автор

Excuse me, Povilas, If I wanted to deploy my API, is heroku an option? Because I did it and it generated my url, but I can't test it in postman

leslysuarez
Автор

API resource is used to transform data when sending the data to clients, but can API resource transform data that is received from external API call?

afiqhamzah
Автор

Is good to use resource in web and blade not only in Api ?

laayounelive
Автор

I just feel using resource is a long thing... it's better you create a return class and map whatever you need to send to the api from the parents. ... this is one of the reason c# net core api is faster. Using resource is bulky

gabrielnzete
Автор

I rarely use this, but this looks very complex man 😬

bboydarknesz