Тёмный

HUGE NEW FEATURE: API Resources (14/14) - Laravel 5.5 New Features 

Подписаться
Просмотров 44 тыс.
% 959

The largest feature to come to Laravel 5.5 is the API resources. This feature allows you to manage your JSON payloads for your API much easier. For those of you maintaining APIs in Laravel, you will begin to jump for joy with how easy this has become.
Think of API resources like templates for your JSON payloads. In the past, previous versions of Laravel would run a simple json_encode on your model objects to return a JSON request. This meant you were outputing a direct mapping of your database (minus any hidden fields you defined). This is bare bones functionality and generally is ok for internal APIs but much more control is required for Public APIs.
Thanks to API resources we now have an easy way to control the layout of our JSON payloads by creating a "resource" and defining the structure in the resource. I like to think of resources as "JSON templates". With these templates we can define the information we want in the resource and even create or combine information from multiple models or nested relationships.
The video explains all of this in more detail than I can explain here, so be sure to check it out.
==== LINKS ====
Documentation on API Resources
laravel.com/docs/5.5/eloquent-resources
==== MORE FROM THIS SERIES . ====
Full Playlist for the “Laravel 5.5 New Features“ Series:
ru-vid.com/group/PLwAKR305CRO8GY3HVpXShlrXab8Cd7VT_
==== FOLLOW ME ====
Subscribe for New Releases!
Subscribe to DevMarketer Insider
[Email Newsletter]
confirmsubscription.com/h/d/5EDC91CF554832D1
Twitter - _jacurtis
(ask me questions!)
==== QUESTIONS? ====
Leave a comment below and I or someone else can help you.
For quick questions you may also want to ask me on Twitter, I respond almost immediately.
Email me hello@jacurtis.com
Thanks for all your support!

Хобби

Опубликовано:

 

24 сен 2017

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 106   
@Osteele
@Osteele 7 лет назад
Sat through all 14 episodes and, as always, your time and assistance is greatly appreciated. Thank you
@7197055
@7197055 6 лет назад
I am new in laravel and going to start build APIs and have learnt lots of things from you. Thanks a lot
@DodaGarcia
@DodaGarcia 4 года назад
Your teaching is very thorough!! Thank you for this video.
@King_Eke
@King_Eke 6 лет назад
This is great, can you make a video of how we can use this to do CRUD functions with the API ? making sure it also checks that it's the admin that's logged in or what not. Thanks
@bloggervista
@bloggervista 7 лет назад
Hi thanks :) Been following this series. Thanks for all videos :) I guess now its turn for build and advanced blog cms right?
@cristalmen9104
@cristalmen9104 5 лет назад
Thank you so much for your vids! One of the most powerful Laravel channels in youtube. Each video in one breath!
@CODINGISEASY
@CODINGISEASY 5 лет назад
he inspired me to create a channel :P
@taloto07
@taloto07 7 лет назад
Hi Alex! Great video. Keep it up. Can you do API authentication and authorization?
@MrGeneticLizard
@MrGeneticLizard 6 лет назад
Use Laravel Passport! laravel.com/docs/5.7/passport
@sokhaitrey9211
@sokhaitrey9211 5 лет назад
Best explain. Please make the video that cover all the advance concept of Laravel. Thank you
@TristanBailey
@TristanBailey 7 лет назад
round about 20mins head exploded with reduced effort to now do this. Looks a handy new to paginate resource collection feature.
@afolabisamuel6992
@afolabisamuel6992 3 года назад
Awesome and Great Tutorial, Thumbs up.
@ozgirl
@ozgirl 7 лет назад
Great videos! Thank you so much for the time and effort Alex!
@penruxtechnology142
@penruxtechnology142 7 лет назад
Maaaan.... this laravel series is awesome... keep up with the good work... love the format of your videos...
@haroldpepete
@haroldpepete 4 года назад
You're the man my friend, if you launch for president, count with my vote
@cristianmerli5050
@cristianmerli5050 5 лет назад
I am used to use DTOs (to hide or include extra fields). Are resources the way to go now? The difference I guess is that with DTOs the extra fields are included in the same object, while with resources you have "data" and extra fields outside of it.
@qcasares
@qcasares 6 лет назад
Excellent​, enthusiastic and insightful.
@daledurham3048
@daledurham3048 6 лет назад
Not sure if something changed or if it's a bug, but when pagination is added, the collection goes back to using the full model (unless overriden on the collection). I noticed yours did not, but mine did.
@sumitsharma-us2sl
@sumitsharma-us2sl 7 лет назад
pretty longer as per regular videos but lots of stuff to cover Thanks for making a great video
@onlineenergy7151
@onlineenergy7151 3 года назад
I love u and u r talking.... May god bless u
@vukasinzurzevic4206
@vukasinzurzevic4206 7 лет назад
GREAT FEATURE! you are good as always, I have one question for you Alex. What is your opinion about Laravel's future? Is popularity of this framework growing, how long is gonna be 'live'? Tnx
@JacurtisTutorials
@JacurtisTutorials 7 лет назад
Laravel is stronger then ever and growing faster every day. I am seeing large companies start to adopt Laravel now because they finally feel like it is stable enough to rely on. The LTS releases help a lot with larger scale adoption as well. PHP has stood the test of time and people continue to come back to it as a reliable way to write code for the web. So having a truly great framework like this in PHP helps a lot. PHP suffered from having way too many frameworks before, and every framework had its own unique purpose. Most frameworks didn't last long, but Laravel has grown like no other framework ive seen in PHP. I really think it is going to grow to the strength of Ruby on Rails. I feel very confident about it. Other technologies i would keep an eye on are using front-end JS frameworks paired with backend APIs (think Vue.js/Angular/React paired with Node.js/Laravel/Lumen backends). I am seeing a lot of development move this direction. Not forgetting server side frameworks like Laravel, but using them for the backend and server side while relying more heavily on JS frameworks like Angular, Vue, and React for the frontend. Another growing trend which I have videos planned for is going serverless. This is especially good to complimenting extremely large projects or overtaking very small projects. This allows services like AWS or Microsoft Azure to run scripts on demand so that instead of keeping a server running 24/7 to handle requests, you just write a script and host it on a serverless platform like AWS Lambda. Of course serverless computing pairs very well with the JS frameworks i mentioned above, cutting our server side. But we are seeing really large companies like AirBnB and Uber combining serverless for microservices and server-side frameworks for the bulk of their backend models and controllers.
@vukasinzurzevic4206
@vukasinzurzevic4206 7 лет назад
Thank you for this comment Alex, Laravel is my first love and I had some projects where I used Laravel for server side and AngularJS for frontend as you said...it's good combination. Also I am glad to see that Laravel still growing and I think it will be great if you do in future some tutorials where you will use Laravel and AngularJS :)
@krzysztofjabonski5572
@krzysztofjabonski5572 6 лет назад
Hi Alex! I know it's been a while since you uploaded this video, but I have one little question. Why are you using web route? Laravel has file called api.php in routes folder and I wonder which one should I use? Can you explain it, please?
@md.shafayatulhaque6273
@md.shafayatulhaque6273 5 лет назад
Thanks Mr. Alex
@nerguibaatarn7572
@nerguibaatarn7572 7 лет назад
Thank you for all series
@ShivarajRH
@ShivarajRH 6 лет назад
Very frequently used keywords are STATUS, with value "success" or "error", with the same level of "data".
@Battlestad
@Battlestad 5 лет назад
Hi. I'm quite new to Laravel. Why is it wrong to just format the data directly in the controller? I dont really understand why we need a new class just for that purpose
@mostafakawsarlive8574
@mostafakawsarlive8574 7 лет назад
Thank you jacurtis brother.
@lserranoit
@lserranoit 4 года назад
Hello, it can be used to send programmer message to the front for post or put request. To send warnings or error messages?
@stephenmccallister967
@stephenmccallister967 7 лет назад
Thanks for making the videos. I am a beginning freelancer and I am in the process of learning laravel and I find your videos very helpful. Any advice on getting started learning laravel?
@CODINGISEASY
@CODINGISEASY 5 лет назад
do you need any help?
@fahimriaz4680
@fahimriaz4680 5 лет назад
Thanks Alex your the best .
@mohamedmohiy
@mohamedmohiy 6 лет назад
thanks for the video, i have a question, what if i want to make many formats for the same resource?
@ryan.aquino
@ryan.aquino 7 лет назад
Make a tutorial on a angular 4 as frontend and laravel as backend plss :))!that would be a great example project for apo requests
@himak21
@himak21 6 лет назад
Very great, useful videos. Great Jobs!! See you next video ;)
@sunaaldua25
@sunaaldua25 6 лет назад
thanku alex for the video... i wanted to ask what if we now have to integrate the api's with a view(blade file)? how can we do it? thanku in advance
@tornikemenabde9188
@tornikemenabde9188 6 лет назад
Sorry for beginner question but why we can't just return this JSON data directly from the controller without API resource? P.S good tutorials thanks for the channel i learned lot from you
@eissa6443
@eissa6443 5 лет назад
Thank you , you saved me a lot of time.
@SilconOne
@SilconOne 7 лет назад
Hey Alex Great work bud. Interest on a tutorial on Cashier and Stripe Subscriptions if you have the time THX.
@bernardchisumo4054
@bernardchisumo4054 7 лет назад
Thank you very much for a nice tutorial . I would like to request a tutorials for the following packages Cashier Envoy Horizon Passport Scout Socialite if u have a time
@roduankd
@roduankd 7 лет назад
is it useful when I use ajax request in my app(meaning is it better to use json and ajax to get my data from the Controllers) ?? cuz I was suffering with json and csrf and couldn't solve it till now!! really upsetting I really hope to undersand it more in the "Curtis" way and Thank u for ur efforts that u ve made in the series it was really helpful for me ;)
@stefanosgiannakis7151
@stefanosgiannakis7151 6 лет назад
Very helpfull '' thanks ! I will be glad if you teach us how to "consume" api's using laravel
@quyettv404
@quyettv404 6 лет назад
hi alex, can you compare API resource with Transformer lib. I think they have the same result. Thank you
@talihaarif9544
@talihaarif9544 3 года назад
Inside a for loop calling the api resource and after returning data from resource pushing in an array. And return that array from resource. sometime it does not call the resource or sometime it call more than required times. How to solve this?
@أسامةسلامة-ع1ف
@أسامةسلامة-ع1ف 6 лет назад
..hi ..i have problem when using paginate .when using resource meta and links not show ??
@roberto9369
@roberto9369 6 лет назад
just what i need. thanks man
@baseerx
@baseerx 6 лет назад
Can you please make a video series on frontend VueJs use with laravel as framework,tutorials on vuejs are custom.
@thegabzboy
@thegabzboy 7 лет назад
So would this replace Fractal Transformers?
@JacurtisTutorials
@JacurtisTutorials 7 лет назад
Yes exactly. This replaces Fractal.
@thegabzboy
@thegabzboy 7 лет назад
Cool...one less package to install
@jonathanespinosamtz
@jonathanespinosamtz 7 лет назад
Hi @DevMarketer I have problems with the relations, if I put only the relation: $this->relation is working, but if I do not want to get all the colums is giving me error, example: $this->relation->id, this return me that Property [id] does not exist on this collection instance. Can you help me? Thank you
@justincv
@justincv 7 лет назад
$this->relation()->id
@ts-nq7bo
@ts-nq7bo 6 лет назад
Can you please make a tutorial Angular js as a frontend and laravel backend
@nenadfemic861
@nenadfemic861 6 лет назад
best educator
@437manoj
@437manoj 3 года назад
Excellent
@paitrex
@paitrex 6 лет назад
Why should we use resources instead of create function in models? How to display hidden values ?
@JenniferJames-gj4ol
@JenniferJames-gj4ol 5 лет назад
love ur efforts
@abhishekjain9037
@abhishekjain9037 6 лет назад
Thanks Alex...
@sumitsrivastava9184
@sumitsrivastava9184 4 года назад
Thank you :)
@mvishalshukla007
@mvishalshukla007 6 лет назад
hi can u please make video on how to enable cors in laravel and about headers
@winwinsp
@winwinsp 3 года назад
Hello Can I send full $user record like return ['user' => $this], please advise. I am getting error like recursive ...
@AavinSeth
@AavinSeth 5 лет назад
In eloquent toJson() how do i change my key name and customized my data in controller?
@neeleshkrishna5580
@neeleshkrishna5580 4 года назад
Hello buddy i just want to change my api url like /api/customer/1 customer is an endpoint and 1 is id of the customer but i want /api/customer/jon where jon is name can you suggest me how can i do that?
@RostikShunlov
@RostikShunlov 5 лет назад
As always u amazing. It's a pity what you disappear from youtube
@CODINGISEASY
@CODINGISEASY 5 лет назад
Im looking for laravel video ideas can I make you one?
@RostikShunlov
@RostikShunlov 5 лет назад
​@@CODINGISEASY as i know, rest full api is good idea for example laravel php its backend with implemented rest service for messages (todo list etc) on frontend you have vue or react for CRUD its only my opinion
@CODINGISEASY
@CODINGISEASY 5 лет назад
I will make a video on it! @@RostikShunlov
@prabhat2k15
@prabhat2k15 6 лет назад
What if i dont have a foreign_key ? How will i relate other table?
@xseman
@xseman 5 лет назад
22:20, well that doesn't work, but call to the another collection works. Great video tho :)
@myohtet319
@myohtet319 6 лет назад
Thank
@peterm.souzajr.2112
@peterm.souzajr.2112 7 лет назад
so cool, basically eliminates the need for me having to have learned 5 languages....
@arvind85ful
@arvind85ful 6 лет назад
Hi, I want to create post request api in laravel.Please guide me..
@shekhsaifuddin1353
@shekhsaifuddin1353 4 года назад
Why are you not create new videos.? Bro..😢😢 miss you
@pooriahonarmand111
@pooriahonarmand111 5 лет назад
Thanks still in 2019
@jboxy
@jboxy 6 лет назад
What's a micro API in a monolithic framework?
@_the_one_1
@_the_one_1 6 лет назад
Hey you are awesome and you know that.Thank you very much for these clear and good understanding free tutorials. But i BEG you!!!Build something great with Laravel & VueJS.Please ?!!? It is the most searchable programming topic. You'll get many thanks for that...pleeaseee
@foysalfoysal4304
@foysalfoysal4304 6 лет назад
Nice one. Go ahead.
@baseerkahn9561
@baseerkahn9561 6 лет назад
Sir,I have a question, if i hit resource controller URI using c++,will it return data in json formate to c++ variable?
@jiansu
@jiansu 6 лет назад
not sure what u mean by using C++ this is PHP. If your C++ app hit the PHP backend what you get is JSON response, Doesn't matter if u r using C++ or C# or Java app to consume it. by the end of day you need to parse json objects
@tornikemenabde9188
@tornikemenabde9188 6 лет назад
why we are saying return NEW userResource, we are not creating we just return existing user can someone explain why we need new?
@CarlosAlbertoBrasil
@CarlosAlbertoBrasil 4 года назад
How can I sort the data?
@Mcakmakali
@Mcakmakali 6 лет назад
I have such a problem :( Command "make:resource" is not defined.
@CODINGISEASY
@CODINGISEASY 5 лет назад
it is php artisan make:resource ResourceName
@arvinkenndelossantos7753
@arvinkenndelossantos7753 6 лет назад
You just saved me from learning Fractal
@cromartie1984
@cromartie1984 7 лет назад
How does you json appears as json, mine does not
@JacurtisTutorials
@JacurtisTutorials 7 лет назад
Chrome extension. Download here: chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc
@jeanandrewfuentes2995
@jeanandrewfuentes2995 6 лет назад
Make A tutorial On Laravel as API Web Service layer to Web/Android/iOs
@MrAKGarg007
@MrAKGarg007 7 лет назад
Hi guys, I am new to Laravel, Can any body guide me, Which version I have to start from ?
@CODINGISEASY
@CODINGISEASY 5 лет назад
I have a beginner setup guide
@anshuverma1182
@anshuverma1182 7 лет назад
php artisan make:resource Product this command is not working in laravel 5.5
@CODINGISEASY
@CODINGISEASY 5 лет назад
resources were introduced in later versions
@Kliamframe
@Kliamframe 5 лет назад
Look at me! I'm watching this video WITHOUT adblock
@shahidb7814
@shahidb7814 6 лет назад
Dear Honorable Sir, Could you please tell me how can I send Username and Password to that User's mail after Registration New User in Laravel ? Regards Masum
@mohammadirvan7308
@mohammadirvan7308 4 года назад
how about many to many relationship
@johndavedecano2438
@johndavedecano2438 6 лет назад
LODI!!!
@DerkJanSpeelman
@DerkJanSpeelman 6 лет назад
don't name your Resource class classNameResource! Name it className only. (like in the video). Because otherwise it's collection won't inherit the return value of the toArray function!
@limitlesskode
@limitlesskode 3 года назад
Is it my eyes or do you look like young Elon @DevMarketer
@thatsenam9183
@thatsenam9183 3 года назад
Mini Elon Mask
@adamsonvispo7915
@adamsonvispo7915 5 лет назад
huge thanks elon musk! please teach us how to hack NASA using html
@lawfirm3843
@lawfirm3843 6 лет назад
talk a lot, seems like reading a book.
@CODINGISEASY
@CODINGISEASY 5 лет назад
:P
@timomuller2162
@timomuller2162 6 лет назад
You are smarter than you look :P just kidding :)
@harunthuo2610
@harunthuo2610 5 лет назад
you're just stupid. come to another man's channel and behave like a 6 year old
@ljka
@ljka 6 лет назад
Thank you :)