Laravel 8 | CRUD API using Laravel 8 Resources | Laravel 8 CRUD REST API | Laravel 8 Rest API

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome back to my channel don't forget to click on subscribe in this video we are going to build a crude api using laravel 8.4 open up a terminal and create a new laravel project navigate to desktop or anywhere in your computer and use this command to create a new laravel project and create a new database i have already created a new database name crude api db in mysqldb okay now navigate to project and open this project with any text editor my case atom text editor okay now open dot env file and configure for database connection here db name my case crude api db username root and password password at one in my case and go to config and open database dot php file and make default connection mysql for mysql database and here type database name crude api db username and password save this file and go to terminal and create a new model and migration using this command esp artisan make a model product and use dash m for migration and hit enter and go to database and migrations open this newly created migration this migration created a table with name products add some column in this table increments id here id column automatically increment that means this column is auto increment field and another column product name this column takes input for product name integer price this column takes input for product price okay now go to app and models open product dot php file protected fill able and here add attributes name and price okay now go to terminal and run this command migrate okay now create a controller for product controller api product controller dash api now create a resource for product resource product okay now open okay go to routes and api.php file and add routes here route http get method to redrive all products so include here product controller plus and with indexed method add name space here app http controller api product controllers okay index and copy this paste here four times and update this this route redrive specific record of a product by id with show method this route used to create a new product record with stored method and this route update a specific product record with id in update method and http delete method and here this route is used to delete a specific product record by id with destroy method okay save this file and go to product controller first create a new product record and name space use f http request use app models product and use app http resources product as product resource okay now create a new instance product new product and getting the product name with reference variable of product class product and name attribute request input name price and price and now save this with in will function save after saving the record show the instance in product resource product okay now start server php artisan server open postman use the route product and here http post method and send jason data name product name laptop and price send this okay we got it now implement index function you get a redrive all product record products product all and now return product resource products go to postman laptop pc create another record isp desktop send now use git method to retrieve all product records okay we got it now implement show method to get a specific product by id my id a variable name product which is reference variable of product object product and here use a function find or fail this means if this id is exist then return the record of this product and now send okay i got it or we can redrive product whose id is to okay now implement update function to update a specific product record create an instance variable product product and find or fail id this means if the record id exist then product attribute getting the form value request input name and another attribute product price getting the request input value of price column and save this by this function after saving return new product resource product okay save this and try to update value dell desktop id2 send okay and the last method destroy we are going to implement destroy method to delete a specific product record by id product and product model find or fail if this id exists then it will be deleted okay this method and return [Music] the deleted records of product product resource product okay now go to postman and delete this okay we have deleted id 2. so get all products records and see id2 has gone okay now go to http providers and open app service provider and go to boot function and use session resource without wrapping add namespace use illuminate http resource lesson and json resource save this and go to any browser and browse api okay if you like this video give a like this video and share your feelings my comments and subscribe this channel for next video thank you so much for watching this video
Info
Channel: OSTechHelp
Views: 3,923
Rating: undefined out of 5
Keywords: #Laravel 8 | Build a CRUD API using Laravel 8 Resources | Laravel 8 CRUD API, #Laravel 8, Build a CRUD API using Laravel 8 Resources, Laravel 8 CRUD API, Laravel 8 CRUD API Using Resources, Laravel 8 crud tutorial, laravel 8 rest api, Laravel 8 CRUD REST API, laravel 8 api crud, laravel 8 api rest, laravel 8 api tutorial, laravel 8 api jwt, laravel 8 api authentication, laravel 8 api example, laravel 8 api development, Build a CRUD API using Laravel 8, Laravel 8 Rest API
Id: WxjFFbHKQ_Y
Channel Id: undefined
Length: 28min 53sec (1733 seconds)
Published: Fri Nov 20 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.