Learn Laravel 8 API Development Tutorial Step by Step | Online Web Tutor | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Learn Laravel 8 API Development Tutorial Step by Step

teacher avatar Online Web Tutor, Professional Web Development Instructor

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

58 Lessons (7h 48m)
    • 1. What you learn in this course?

      3:33
    • 2. What is an API?

      5:40
    • 3. Discussion About Course Structure

      4:24
    • 4. Laravel 8 Installation

      5:36
    • 5. Create Application First Program

      11:17
    • 6. What is Migration & How to Use it ?

      11:22
    • 7. About Application Model

      8:52
    • 8. About Data Seeders Concept

      13:53
    • 9. What is Middleware, Types & Use?

      9:39
    • 10. About Route Group & Route Prefix

      9:03
    • 11. Application Installation & Settings

      11:03
    • 12. Route, Migration & Model Settings

      13:32
    • 13. Functions of Create API

      11:12
    • 14. Functions of List API

      4:17
    • 15. Functions of Single Data API

      4:35
    • 16. Functions of Update API

      9:48
    • 17. Functions of Delete API

      5:36
    • 18. Application Installation & Settings

      5:13
    • 19. Migrations Setup

      5:32
    • 20. Model & API Controller Settings

      5:51
    • 21. Installation of Sanctum Package & Settings

      6:38
    • 22. Define Controller Methods

      8:42
    • 23. Create API Routes & Sanctum Route Grouping

      7:01
    • 24. User Register API

      11:51
    • 25. User Login API

      11:43
    • 26. User Profile API

      5:18
    • 27. User Logout API & Delete Token

      5:50
    • 28. Create Project API

      9:40
    • 29. List Project API

      6:34
    • 30. Single Project Detail API

      9:17
    • 31. Delete Project API

      7:33
    • 32. Introduction about APIs & JWT

      8:08
    • 33. Project Setup, JWT Installation & Configuration

      10:48
    • 34. Migrations Setup

      5:27
    • 35. Settings of API Models

      6:30
    • 36. API Controller Settings

      11:08
    • 37. Creating API Routes & Middleware

      6:01
    • 38. Create Register API

      9:20
    • 39. Create Login API

      8:17
    • 40. About Profile API

      7:46
    • 41. Logout API Function

      4:51
    • 42. User Course Enrolment API

      11:39
    • 43. Total Courses API - One to Many Relationship

      6:52
    • 44. Delete Course API

      5:05
    • 45. Introduction about APIs & Tables

      3:59
    • 46. Project Setup, Passport Installation & Configuration

      10:44
    • 47. Create API Models & Migrations

      9:41
    • 48. Create API Controllers

      9:04
    • 49. Create API Routes & Passport Route Grouping

      7:16
    • 50. Create Register API

      8:27
    • 51. Basic Guard Settings & Create Login API

      12:57
    • 52. Create Profile API

      3:55
    • 53. Create Logout API

      6:24
    • 54. Create Book API

      9:33
    • 55. List Book API

      11:46
    • 56. Single Book Details API

      6:45
    • 57. Update Book API

      10:10
    • 58. Delete Book API

      5:32
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

188

Students

--

Project

About This Class

Bit Experience in Laravel programming required. Learn practical skills of Laravel basics, api development in laravel 8 framework with authentications. Enrol this course today and get the skills over laravel to develop yourself as a standalone api developer.

Begin your journey of Application development in API Development in Laravel 8 - Passport, JWT, Sanctum.

If you have just decided to learn api development in laravel programming with authentications then you have made the right choice, so take a breath. API development i.e Development of Laravel APIs is very easy to learn which means that you will be through the basics and on to writing module wise code for application with standards in a very short time.

This course is a step by step guide through the Laravel framework, and mysql programming language. You will go from a complete laravel framework beginner, from installation to creating your own application.

There are over 57 lectures in this course and over 8 hours of video each one detailing a specific aspect of the api development concept in laravel framework programming.

This course will walk you through:

We will create APIs in laravel framework using authentication systems.

Laravel Basics
About Models, Routes, Migrations, Seeders, etc
Laravel Artisan Console
API Development Without Any Authentication
API Development Using JWT
API Development Using Sanctum Token
API Development Using Passport Authentication
MySQL Queries
API Development standards
Get programming with Laravel Framework with API Development today and enroll now.

Meet Your Teacher

Teacher Profile Image

Online Web Tutor

Professional Web Development Instructor

Teacher

Online Web Tutor is web development community found by Sanjay Kumar. This community have professionally trained instructors, developers. It provides web development course for free worldwide. It contains approx 1000+ videos of different different technologies like Wordpress, PHP & it's frameworks, Js & framework etc on Youtube.

 

Additionally we have services for web development training, handling client projects, one to one tutoring etc. Check our services at Udemy, Blog, Youtube.

Please do your support to community and help us to grow.

 

About Author

I Sanjay Founder & CEO of Online Web Tutor and Professional Web Development Instructor. By passion I am a web developer. At free time I used to write programming blog articles,... See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. What you learn in this course?: Okay guys, vacuum for glucose level eight, EPA development. This is all very first video that is Course Overview and satisfied you too will see that what are the things actually we will cover while going through this lab relate API development course. So here we have some bulleted points. So this course will be step-by-step lab 8 API tablet meant. So in the very first lectures, frequency, the complete basics of level, so that we can enhance our label to actually create APIs. So before creating any of the APIs inside the schools, we will see some basic concepts of level that is, models, routes, route prefixes, route groups, middlewares, migrations, setters. So all these things we will see before creating any API. So after getting the concept of these basics, now we have increased our label to develop any API inside lateral. So in the second means, after these things, we will see API development without any authentication. So heal without any authentication means that inside this goes for will actually include sanctum, JWT and passport. These are authentication system we will include inside the schools. So first of all, we will see that EPA development without any authentication, without including all these systems. And 10 for really start all about the second phase of development, that is EPA development using Santa token. Next, cruelty the concept of API development using JWT token. What is the structure of a JWT token? For it is the structure of sanctum. What is the basic took on a structure of passport. All we have discussed inside the schools and he'll API development using passport inside the schools. Also we get the concept that is, what is the difference between sanctum JWT and passport? In which application label we need to use. These tokens is specifically we have discussed inside the schools and also vile. Going through this course, you will get all about the information of handling each user tokens and processes to develop any kind of APIs. So this course will be very interesting to learn. So I suggest this course will give you the complete idea or overview to develop Level 8 API development using any type of authentication system like sanctum, JWT, and passport. And one more thing that after getting the concept of this course, you can handle the EPA development of e-commerce sites of all, let's say any type II type of level project means. Now we are ready to handle user tokens, how to process it? How can we transfer to come from 1 to another voter? The endpoints of EPA's means, all these concepts of EPFL print you will get inside this course. So I suggest enjoy this course now. And if you have decided to learn all about legal aid, EPA development, so this course will be best for you. So far. This video session, gas, thanks for watching and have a great day. 2. What is an API?: Hello guys and welcome to the course of lauryl eat EPA data points Turiel, this is part 1 and satisfied you for we'll discuss introduction about API if I back to slide. So inside this slide, we will discuss are very precise definition about an API. So the first question before starting this course is all about that is, what is an EPI? So EPA is the acronym for application programming interface. The DOM E is coming from application. The P term is coming from programming, and the item is coming from interphase. So EPA is the acronym for Application Programming Interface, which is a software, which is a software intermediary data loss do applications to talk to each other. For example, here we have some examples to understand about an EPA into a deeply will. So the first example is something like COVID-19 APIs. So for now, in this pandemic situation, we have some labs which is displaying COVID-19 data. So how we get those data by the help of APIs. So if I go inside this Google and search about COVID-19, EPA's, as you can see that we have several links hill. So randomly, I have clicked on this link and fear getting a Postman collection link inside this. As we can see that we have several EPA here. We have like summary by using GET request type simply if I copy this URL, go heel, pressing enter. And as you can see that by the help of this EPA goal, by using GET request type, we're getting our data into a raw format. The API returns data into a JSON object. Inside this JSON object, we have few properties, as well as another object inside this parent upset. So currently the data is enjoy format. But when we display inside any mobile application, only seen site of application, simply we need to parse and display into our desired format. Like if we want to display into Tableau format simply we can done that. If we want to display into some graphical representation simply we can read data and put inside charts. And so like with the help of pie chart, graph chart or any other chart types. Now the next example we have something Facebook APIs. As we know, Facebook provides a Messenger app. So inside Messenger app to get instant messages behind the scene, facebook uses EPA's concept. And for the notification, let's say for the CFD Post like and comments, we get all the modification by means of APIs. Now next we have APIs for weather report. As we can see nowadays in our more while we have several applications installed, it actually provides weather report data. So Farmville data application collect data simply behind the scene. Also, it caused the APIs to get our vendor report data by getting data into raw format, simply vars and display into tabular format or by means of some graphical representation. So here we can understand by the help of this line as well. Here we have back-end server, which provide back-end data. This data is in raw format. Now here we have application types, let's say mobile application or web application. So to display data to end users, like mobile application or web application, the need data. And as we know that data is stored inside this backend server. So EPA is the connector which connects back and silver takes the raw data, convert into JSON format and give it to this mobile application or VBE application. So simply, these application parsed the raw format of data and display into desired format. So that's why. And to this definition, as we can see that EPA, pretty soft, very intermediate that allows to applications to talk to each other. Here we have application fun, and here we have application to deal talking to each other means here we have the data and here we have the end-user interface. So data is sending to this end user. And the user is requesting data from backend server. And the whole process is going by the help of this API. So EPA is data carrier. So in the next video, what we are going to learn inside the schools, we will discuss in detail in the next video. So far, discretization guys, thanks for watching and have a great day. 3. Discussion About Course Structure: Frank and glucose level eat EPA Gallup material. This is part 2. Inside the suite you will see all about goals in production. If I back to slide, in the last video, we had seen the really basic concept about what is an API. Now inside the sweet you for we'll discuss all about the course structure, what will follow and proceed in EPA development of lateral. So here we have the course structure that is EPA developing in Lanval eight. So first of all, we will see the concept of basics. Inside these basics, we will cover all the concepts about route control law, model, migration, CDL, middle, we'll route, group and prefix. So this is a very basic concept of level we will discuss before API development. After going with each video, we'll create our concept so that you will use these concepts in the further development of API development. So at the first stage, we will have the plan to cover the basics of lateral. Now in the next phase, we will double up normal APIs. It means we will create a setup. The first installation of larval eat. Inside that setup, we'll create normal APIs. Normally EPA's indicates that those APIs, without any authentication, you can easily access any of the route of those APIs. Now we will go for inside this phase 1. Now in phase two will increase our label and we'll include authentication system. So at first, we will create our larval eat APIs using sanctum authentication. So sanctum authentication is a very lightweight feature included from larval sound version. You will see that what is the use of sanctum authentication and how it is beneficial after going through sanctum authentication. Now next we will create, again a blank setup of lateral eight. And this time we'll see all about EPS element using JWT authentication. So inside this, we will see that what is the structure between means is structured difference of token between this sanctum JWT and passport. So he'll inside this free 3 of EPA development, we'll, we'll use JWT authentication also will understand about the token is structured. Inside this phase two and phase three, we have included all about authentication. Now in the last pool, include the final authentication inside Lab 8, that is passport. Again, we will create a blank setup. Inside this blank setup will create Migration API controller, APA models, middle wheels, route group. And this time we'll include as Passport Authentication. So inside this whole course structure, as you can see that reoccurring level basics after that via developing normal EPA's where we don't need any authentication. Now in the next level, we had included sanctum authentication, DWT authentication, and password authentication. So a step-by-step via covering lots of thing inside this API development goals. After going through each video of this course, you will be able to develop any kind of APIs in lateral aide using all types of authentication like sanctum, JWT and passport. And also, you will understand that what is the difference between this sanctum token, why we use it? What is JWT token? What is structure and how can we install passport and configure inside application. So from the next video, we'll start from the installation and see about basics of level. So far this utilization guys, thanks for watching and have a great day. 4. Laravel 8 Installation: Hello guys, vacuum to the course of lauryl eat EPA database tutorial. This is part 3. And scientists feet you vim to install lovely setup as well as we will configure database configuration. So if I go back to the official website of lauryl.com, click here inside this documentation. This is the fourth video to start all about EPA development. So first of all, we need to install larval eat setup. Now inside this guide, we will find two different way to install lauryl ether application satyr. So for this video, for this course, I will install via composer. So if I scroll down, as you can see that inside this documentation we have a section called Installation via composer. And one more thing to run or create proceed via composer. You system must have composer installed. How can we verify that in my system, composer has been installed or not? So simply, if we pack the terminal and type the command called Composer, pressing Enter. As we can see that via getting our list of commands and that description. This is green verifies that composer has been installed in my system. If you are getting some error. Or let's see the screen, which is not something like this. Eight mins in your system, composer has not been installed. So first of all, to create Prozac via composer, your system must have composer installed. So I assume for this video is that your system must have composer. So to copy this command, that's terminal. Now currently via inside VAD, WW at DML and lateral fold. You can choose your own part. Now here's the command composer, create, present larval foods less novel. And I will name the project here something let's say lateral underscore hyphen API. This is the project name. So simply and pressing Enter. Now as you can see that the installation has been started and it is installing the version 8.5.14. So we need to wait for a vial. And successfully, as you can see that the installation has been financed. So if we go inside this directory structure, now inside this lauryl photo hills the photo what we have installed. So if I open this folder into VS Code, you can open this folder inside any of your favorite editor. So successfully we have installed now in the next way to connect with a database. So first of all, we need a database, so forth that we will go inside this PHP, my admin, click on Databases. And let's say that larval underscore API. So if I press Enter database created successfully, right now there is no table. Back to editor. I am opening dot ENV file because as we know that to connect database, we normally use dot ENV file. It stands for environment variable files. Now inside this file, you will see all these variables like DB and the school connection, host, port, database, username, and the password. So simply inside this database, I will pass the name, what we have preheated, call wearable and the EPA. In my case, that username is admin and the password is something admin. At verse 23. In your case, it may be different. So successfully now we have connected the database to this application. Now next, how can we run this application to browser? So simply go to terminal V to go inside our project setup. So as we know that we have created CD larval hyphen art. I think EPA, this is the folder what we have created. And simply to start developments of simply type BHP artesian serve. So it will start the Prozac into our development server at the port 8000. So if I press Enter. Now as you can see that this is our development server. Produce started at 8 thousand boot. So simply if I open link, it will go into the browser. And as you can see that successfully we have installed the lateral setup into a local system. 9. The next video, we will see the basic concept like Controller, model, routes, CDO, migration. These are all basic concepts from the next video. So far this video session guys, thanks for watching and have a great day. 5. Create Application First Program: Please welcome to the course of eight EPA development Turiel, distance part full and satisfied you will need to create our first program inside live. So if I go back to folder structure, this is the application what we had installed inside last video. To create first program, we need the route. We need a controller as well as we need a layout file. So a step-by-step, we will create all these files inside this application setup. So if I back to terminal, first of all, we will create our controller. So to create controller will use a command that is command provided by lateral something, BHP attrition by the help of addition command that will create controller. So go heel. Now if I type the command called PHP artesian, pressing Enter. After typing this PHP addition, it is going to give us a GOT command valid. This is the command palette, which is going to actually provide several functionalities, several features when we run any command from this command palette. So for now, let's that if we're interested to create any controller, coincide this mix section. Inside this mix section, we have a command called may colon contour. So when we run the command called PHP addition as a prefix. After this BHP addition, when we type Make controller, controller name, we need to pass, then it will create a new controller class. Now, if we want to learn all about, let's say, if we are interested to see the help manual of dismay controller command, simply go here and type the command called PHP addition help for the help manual and the command name. So we need the help manual guide for this Macon to LA pressing Enter. Now as you can see that this is the help manual guide of Make controller. So when we use this may come to little v to pass an argument. And that argument is something the name of the class. And heal, we have several options. What actually optional if we want to pass while creating this control law. So right now, this is our very first program. So simply, we will create a very basic controller without any options. So let's have BHP artesian mic controller, and we will call it as das controller. Now pressing Enter, as you can see that controller created successfully. Now if you go inside this application structure, so free, we will find that file. What we had created via BHP artesian. So we had created a controller. So controllers by default will install inside the setup, inside this app folder, STDP controllers. And here we will find dust control law. So this is the skeleton nine cytoskeleton through we'll add our mattered. So let's public function. Now inside this, let's say we're creating a sample method. Inside this will pass for now, or static masses, Let's say we can add to an element. And welcome to come to low. Now save the change. Now next we create our route so that when we call that route into the browser, that route will point or call the sample mattered. So for route configuration inside this setup inside lauryl application for will go inside routes folder and open vat dot PHP. In the next videos, when we learn about EPA development, api dot PHP file will be used. This is for APA towel append, and this is for web application development. So if I click on this file, now go here. By default, it will provide a welcome page. So inside this file, first of all, we'll use this dust controller, so we need to import that. So use tasks too low. So successfully we have imported this test controller is coming from app as to TB and controllers folder. If you go to its namespace app as TTP going to lose. And inside this controllers filter, we have dust controller, pseudo hill. Let's create a route that is with the GET requests type. And inside this we'll call it a sample making an array. Inside this, we have the task controller. And inside this dust controller, which is a class. And inside this class, we will have this sample mattered. So if you save all the changes, now we have configured or glandular controller and added a route inside this VIP dot PHP. Now next, to test this application, we start our development server. So PHP addition serve. The application has started into 8,001 port. So if I open this link into the browser, this is our landing page. What we had seen, the help of this route. We will understand in a bit. So for now, this is the road but we had to test. So simply I will copy this route back to browser and type the name called sample. And as we can see that this is the static message. What we had supplied inside this sample mattered. This is only for the static message. Now let's get that view to create our view file. And we will turn to the message from that file, suit it to return or to use a view file. We'll use view helper function. So let's return. Few, we will create a sample file. So let's sample view. This is the name. And inside the application for the Vue file, we have the template engine, which has the extension called dot bleed dot PHP. It means this is the view file. We'll call this for this mattered. So when we create this view file, the finally we something sample hyphen few dot, dot PHP, dot, dot PHP. What is this? This is the extension of land will bleed templates. So if I copy this name, all of your files will be created inside this resources filter and fuse folder. So go Hill, sample view, dot dot PHP. Now inside this file, what I will do simply, I will copy this static message, go Hill, and let's say calling from view file. Now if we save successfully, we have a link to this file into this sample method, really returning heel. So save the changes going to load this page. And as we can see that via getting that static message, in some cases, if we want to pass some values, dynamic values from this method to this view file. We can also pass that, making the second parameter hill, passing an array lists it that name equals 2. This is the name Via passing email. So heel, we have two key value pairs in terms of an array via passing Few file. Now inside this view Phi, all these values will be available. The thing is that these two keys, now they will appeal as a variable inside this view file. So to print, Let's have PHP. And if I type equal name, if I wrap this into a paragraph tag, Let's open up the second paragraph, basing a tail. And this is for the Emulab trees, not save the change going to allude. As we can see that this is the name and this is the e-mail value. We have the salt AND operator of this PHP syntax. Inside the syntax, as we can see that to print any value, this is the land. So is there any shortcut way to print any value inside PHP? Just we have for the SWOT good fat we will do simply get rid of this PHP and equal in place of tat, simply put equals to sine. For this PHP and equal, put equals to sine. All we have done, save the changes, go and reload this page. As you can see that we have the same output. And the last thing for this feature is all about understanding, all about this route. So round cat, it wins for the welcome page. And here inside this callback function, really turning off your file. As for the video, as we know that if field turning any few file. So the view file name Health extension called blue dot PHP. So this is the file we're returning. This file will be available inside resources fool to be useful to and look at this file. Welcome to how to bleed dot PHP. And this function is known as closer function. So this is an example of sir route because this route is not using any contour. Instead, here we have the first value as the route. And the second value we have the function means callback function. And inside this callback function, we are returning of you file. So this is an example of clues around. So as this is our first program, so all we have the concept we had discussed. Now in the next video, we had seen or will see the concept of migration inside lateral. So far discretization guys, thank you for watching and have a great day. 6. What is Migration & How to Use it ?: Hello case Falcon glucose level eight, EPA data pictorial. This is part five. Inside this video, you will see the concept of migration and it's very basic commands. So if we pack to present setup, in the last video, we had seen our first program inside lateral. Inside that video, we had created a controller or simple route and a few file. Also we had seen a concept, something called BHP optician. So PHP addition inside level is a command-line tool or C command line interface which interacts with larval application. So if i back to terminal, if I type the command called PHP partition. Now as you can see that we're getting a command palette. Each command of this command palette is for us for some specific task. In the last video, as we had seen that by the help of this Macon too low, we have completed the task of getting a new controller class. So each command of this PHP addition is created to complete any single specific task. Now from this command palette and this time we will see the concept of migration. So we will use a command from this command palette, something called meek migration. And here's the command. The description is something heat a new migration file. So before you starting this migration, first of all, we need to understand that what is a migration file? So migration file is a file which is going to provide a table is structured. It means inside this file, we'll define the structure something, let's say for the users table, if we want some columns like name, email, phone number. So we will specify the name of columns as well as the datatype. Optionally, we can pass science as well. So these are the things, means, the structure related. These are the things we will define inside migration files. So let's get started all about creating migration file. So firstly, you, when we create any migration file, it will go and is 2 inside this database. And migrations filter. By default. When we install our lab setup these three migration files, we will get inside this set. So when we open any of the myosin file, as we can see that it's a class. And inside this class we have two methods called up mattered and down mattered. Up method is going to provide the schema. Or we can see the architecture of the will. And the down method is going to simply drop that table from the database. When we migrate, our migration into the database, the migrate command behind the scene use these up mattered. But when we run rule back command means dropping a table. So behind the scene, don't matter. Beautiful book. So let's create a migration file. Inside that migration file for we'll define a table is structure, add few columns and migrate into database. So if I open, let say a detour something called g at IIT inside this water will do, we will create a students table and say This is too unstable. We will have the column called name, e-mail lists, each and something, let's say four and the school number. So these are the columns. And one more thing, let's hit gentle. So these are the columns willing to define inside students migration. So battery terminal. First of all, we will define a migration of file. So BHP artesian lets him meek migration and we'll create, let's say, reheat. Under school students. Understood TBL, or simply we will call it as something like this reheat student's day bill. Now if I press Enter, as you can see that migration created back to full destructure go and elude. And here we can get the migration file for our students tuple. So by default, it provides the ID column and two timestamp values like created at and updated at. So what we found FEV1 few columns, let's say for the name suitable and for the name. We need to store the name value into a varchar field. So it will be off a string type. So we need the columns as needed. So inside this string, Let's pass the name column. This is the column name. And optionally, we can pass the land of the field. So this is 120 characters. Next we need for the e-mail address. So if I copy pasting it, he'll email field, let's say it is of 80 characters in length. In the next vivo want each table, it should be then teaser values. So in TSO each and this is unsigned. Now next, reward for number. So phonon ways also the string value, but in this case it is of 20 characters in land. And finally, we want a gender column. So he'll, instead of a string, Let's pass. And here inside this e-mail, as you can see that the IntelliSense is that the first VDD to pass the column name solutes, it is the column name. Next we have the array. Inside this array, we need to pass all available options. So inside gentle V1, something male, female. Now if you save all the changes. Now next, if we want to migrate this migration file into our database, what we had created inside last video, this is the database we have configured, bat terminal, PHP after chin and type migrate. This command is going to run all the pending migrations and migrate into our database. So if I press Enter. As you can see that create users migrated. And here we have some added that is column already exist, duplicate column name called email. So I think that inside our students migration, we had actually written two times email address. So here is the male first, an email. Actually this is for number. So again, if I clear this console, run one more time PHP addition migrate. And before that, what I will do simply take all the tables from db, go inside her eyelids a drop. I will drop all the tables, no devils accessed and run this command. So users table created password resets, fields, jobs. And finally, the table that we had created call is to Dan's back to browser, reload this structure. And hence we can see that V have a students table. Go inside this structure. Here are the columns called Nim, eBay, age four, number and cento. Look at the datatype called varchar, 128 characters and lend 84 known bot enumerator without all possible values. And by default, three columns added called ID, created at and updated at. Now if we want to drop all the tables thought we had tr1, simply go heel and type the command called BHP or Titian, migrate, cool known and pass a flag called rule back behind the scene. When we had to run this command, 8 has actually executed the OK method of every migration file. But when we execute this command, PHP additional migrate rule back, it will go and find the last migrated files and turn that down mattered. So when we run this command, it will search for the latest migration of what we had done. So these all migrations, what we have migrated. So it will go inside each of the migration file and turn that down mattered. And inside down method, we had to come on to drop the table. So if we go and pressing Enter, as you can see that it has ruled back, all the tables go into load this structure. And as we can see that we don't have any key Billy. Now again, if we want to migrate all the tables, again, we need to run the same command called PHP artisan migrate. Is there any command to migrate only see, Is there any command to roll back fullest and migrate us. We have we have the same command Lipset that if we run this migrate command, it has migrated all the tables inside the database. If we go and see who will have all the tables. In some cases, first, v1 to drop all the tables. And in the next, we want to create all the T-bills. We want to execute two different commands, but inside a single line. So simply type BHB addition, my greed. And here we'll type called refresh. If I press Enter. As we can see that first, it has ruled back all the tables, and in the second stage, it has migrated all the tables. So this is all about guys migration, which has provided the table schema for the database. And as we know that the T-bills are the storage area, we'll put our data. So in the next video, we will discuss the concept of Cedars. By the help of C2s, we put our dummy data or fake data for the purpose of testing. So far this video session guys, thanks for watching and have a great day. 7. About Application Model: Hello guys, vacuum glucose level eight, EPA Dallas Turiel. This is Part six. Inside this video, we will see the concept of models inside layer of L. So if I back to fool the structure, in the last video, we had discussed the concept about migrations. So if I go inside database migrations folder. So inside last video, this is a migration file that we had created. And also we have updated inside this schema mattered. We have added few columns like name, email, phone number, and Toronto. And successfully we have migrated. This is Trinity will into database. Now inside this week you will see the concept of models. So what basically models are? So models are those file inside larval application, which is going to interact with the database tables by naming convention. As you can see here, the table name college students is plural. But when we create a model of these students table, the name of the model should be singular. So if I open or GAD glitzy a slider. So by naming convention, if we are creating tables inside lateral, that should be plural. So as you can see that we had created a t, we'll call it students. But inside this video, we will create a model which is going to interact with this is students table and the name suit be singular called student. So when we create a model, the singular name automatically liable, understand that this model is going to connect with this plural name. Something like a student is connected with their students table. If suppose we have like employees table. So when you create a model with the name something, let's say employee automatically lateral bind. This model predicts that obesity will. But two, what will happen if suppose we have a different table name and we have a different model name. So don't worry at all because inside the model we have some member variables. So inside our model rehabilitated table variable. So by the help of data table variable, we will configure data table name inside that variable. So we will assign different table name with a different model name. So we will understand this scenario. In this case, the name is singular. Modeling may similar, but the table name is plural. So inside this application, as we know that we have a model means we have a t, we'll call it students. So film to create our model. So as we had discussed that models are those files which is going to interact with the database tables. So when we operate with any operations like reheat, update, delete, read means by means of any operation to the database, then models should be used. Models are the response will file, which is going to connect application. The database and handles all about input and output of data. So let's create a model. So we will create a model inside labile application by means of two ways. Either we can create the man will coincide app and models fooled vending. Create any model. It will go and is 2 inside this model's folder. So this is the man will be by going to these models filter and creating a model file. But we will use the addition command. So here, if I type the command call VSP partition, pressing Enter. Now if we go inside this may command palette. Here we have the section of May command pilot. Nine scientists may command. Here we have the command called Make model reaches going to preheat on new adequate model class. So we will use this PHP optician make model command to create our new eloquent modal class. So what would the syntax simply if I type PHP, addition, Lindsay make model. And as we know that we have a table call is students. So we need to create the singular name of that table. And that is something called student. So when you press Enter model created successfully. So when we create any model, it will go and install inside this app and models photo. So when we reload this, again, goo, and as you can see that we have a file called student.name PHP n, which we have a class. And there are some packages by default automatically inputted. So when we will do any query by means of students table, we will use this student model to understand all about the variables. Hopefully will for this model glass. Simply go inside this official website of Laurel, that is level.com. Click here in the inside documentation. Go here inside this eloquent ORM. Say simply click on that. Click on Getting Started. Now, all the detailed information about our member variables of any model class, which is associated with little table nim, primary key, and several variables. So simply to understand all the concepts in detail. Coherent side this a first of all down, here we have Argument Model Convention. Now this is the model what we had seen. So in case if suppose we have a different table name, simply v have a table protected variable inside model. So when we see this is the model called flight. So by naming convention, the table links should be plural, which is flights. But inside this case, the table name it something different. So by specifying this table variable as a protected access specifier, we can pass our own table name. Now next, by default, larval understand that when we delete any tuple, the primary gaze by default, the id column of that table. So here inside this, students, as we know that by default, ID is a primary key and auto-increment. But in case, let's say that we have some different table in which the ID is something like student underscore ID, employee underscore ID. So how can we tell larval that this time we don't have ID column as a primary key if we have something different column name. So as far as we had seen for the table, so for the primary key, We have one more variable called protected primary key. These are predefined member variables. So here inside this primary key, simply we need to write the name of the primary key, what we had done, or a specified inside of a table. So inside this documentation, we will see about each variables. Let's say that this time, this ID column is a primary key, which is a type of big end. But in keys, in some tables, if we had the column which is primary key of a string type. So simply we have another variable inside modal class that is protected key type. And inside that key type vi to pass the datatype of the primary key. So inside this documentation, if we can find the complete guide of eloquent model. So in the next video, we will see the concept of Cedars. By the help of Sita's fie. Fie will cede some dummy data inside our data obesity will. So inside, That's the concept. We will use the concept of migration as well as the concept of model. So far this realization, casting for watching and have a great day. 8. About Data Seeders Concept: Okay, He's vacuum glucose level eight, EPA Dallas material. This is Part 7. Inside this week you will see the concept of data CDO. If I backed Prozac, etc. In the last videos, we had discussed the concept of migration as well as the concept of model. So by using the concept of model and the migration table, now this time we will see some dummy data inside our students table. If I back to browser, this is our database. And inside this database, we had created this student's table. Right now, there is no entry inside the steeple. Now we want some dummy data inside this student's table. So to do any entry, we have two options. Either we can click on this insert. After clicking on that, we need to pass the mammal values and click on coppa 10. But it is okay when we're inserting, let's say five or ten number of rules. But in case if we want to insert ten thousand, ten thousand of number of rules. So in that situation, this trick will not work. So inside that situation, we will use the concept of CDO. So by the help of data CDO concept, we can seed dummy data inside any of the table inside liable application. So inside this T-bill, call it student, the structure is something we want and mean value, email each phone number and gentle, because a rest three columns, lists id created at and updated at for these two columns, we have the By default value as the null value. And this is primary key and also it is auto increment. So we want only five mins value for five number of columns. So how can we start with the cedar concept? Back to fool the structure? So when we create any dataset of phi, which is going to help us to see dummy data. It will go and store inside this database. And we have three folders. So inside database we have three folders about these migrations. We understood inside last V2s. Now inside this folder, we have two more folders called factories. And see does. So factories are similar to CDO. When we create any factory file, it is also going to see dummy data inside the will. So by the help of factory concept, as he does concept, we can see dummy data inside our table. So we will see the first all about the concept of factory to seed dummy data. So if i back to terminal, when we type the command called PHP addition, inside me command palette, we will have the command call. If we go inside this may command palette. As you can see, we have the command call meek factory. So it will create a new model factory. So by the help of concept of factory and model, factory is going to produce the dummy data by the help of figure library. And ten, by the help of this model, it will insert all those dummy datas inside this table. So far tes, we have an article. So go inside this blogging website, articles, lateral aid, and click on the Search bar a phenotype. Let's a CDO enlarge. So if I press Enter, click on this article, as you can see here. Now inside this article, we have the concept of using factory and figure library and fit the model to seed dummy data. So if I scroll down, we have the complete detailed concept inside this article. So we will use the factory. So here's you can see that using flattery file to see data inside level. So firstly, we need to generate olfactory file. So PHP attrition make factory. This is the syntax what we had seen inside this terminal command. Now next, we need to pass the factory name. And we will create this factory for student t will simply, in our case, we're just moving with the example of students. And we had created inside last video the student model. So this command is totally perfect. So copy that command. Go hill. Via currently inside this lateral hyphen EPA folder, we are creating a factory with the name student factory model, student pressing Enter factory created successfully. So if i back to our project folder, coincide database factories, and here we have the file called student factory. So by default inside this definition method, really turning an empty array. So inside this array, we need to specify all the columns, what we have inside our student model table. So this is two and Table model pointing towards students database table. So simply V to specify all those five columns inside this return array. So if we go heel and simply, if I copy the whole code of this definition method, go Hill, pasting heel. Now, what are the columns? V1 to V1 something name, email it. So here's you can see that name e-mail. Here we have the ij. Next. We weren't phone number, so I will copy this column knee replaced with this mobile. Next we have the column as gentle or Liddy. Here we have inside this gender the available values we have called male and female. So we don't want anymore with this others option. And also. We don't have this address in fulfilled. And unmuting that this vehicle is the by default figure library. We're using door of this lauryl satyr. By the help of this figure instance, we're using some properties and methods. As we can see, name is a method. Save, email, phone number are the member variables. And these fecal is an instance of Faker laboratory. By the help of figure library, we can create fake data. So simply, all we had done the setup of this student factory. Now next, what we have to do, ready to go inside our database c2 dot PHP file. So simply go heel, coincide the cedars database CDO. And inside this database CDO simply going to copy this command, go Hill, basting a tail. So here what we are doing simply, this is the student model inside last video, what we had created. So by the help of this model via calling our factory file. And by the help of factory file, we're generating a 100 number of dummy rules. Now next, what we have to do simply back to terminal window to know a factor file. For that, we need to run our database cd dot PHP file. So we have a command which is going to run our database cd dot PHP file. So commanding something BHP artesian db seed. So if I press Enter, as we can see that database sitting completed successfully. So if i back to browser, go inside this table, click on Browse. And he'll veer getting all about 100 number of rules with the fake name, female, fig, each value fake phone number, and frag gender value. So this is all about guys. That is how can we use factory to see dummy data inside of our database will. Now next, we will use the concept of CDO and see that by the help of a CDO file, how can we seed dummy data? So back to blog article. If you go up. So he'll using figure library in CDO file. So we need to compute first or pseudo file. So how can we create if I type the command called PHP artesian coincide me Command Palette. And inside me command palette, we should see a command called M60. Do. This command is going to create our new pseudo-class. So we want to seed the dummy data for a students table. So what I will do, let's have BHP, artesian make cedar. It says student CDO. Pressing Enter seed created successfully. So if i back to present Sutter, reload that coincide database CDOs. And here's we can see that we're getting. And I think that I misspelled all about dispelling. So don't worry at all. This is to consider what we have created. So right now inside this run method, we don't have any good. So back to blog article. So what I will do simply if I copy the whole code, go here inside this run method and pasting it here. So first of all, via using this DB glass. So if we need to import, so use dB. This DB class is coming from facades. And by the help of this DB, we can use the Query Builder approach and heal. As we can see that we're creating the phaco instance. As we told earlier, that the fecal is a body for Labaree awfully will inside this alarmingly aid application to generate fake data. So simply, we're using, using these fico instance. Now here we are using the Query Builder approach. So DBT will students means inside this table we want dummy data. Insert method. And he'll, we're creating an array. So inside this area, we have the column has name, email, and the next column we have something, phone on the school number, age, gender, and we don't have like address info. So I will remove. And also we have Dawn option all about others. So we have created this student's seat of file. Now next, how can we run or execute this file? So we have two options. Either we can load this class inside this file or simply bypassing a glass flag. We can directly run this file inside our terminal. So if we want to load this class inside this file, simply what we have to do read to use this goal mattered. And inside this goal mattered, we need to pass our class names. So we have the class name as students, cedar. And we had done that. So by the help of that, again, we need to run the command called PHP artesian DBC. So when we execute that command, it will automatically call this phi and run this run mattered. Now in the next approach, if we want to execute this file directly, we need to pass the class flag inside our command. So if I copy this command, patch terminal, as we can see that VSV addition DBC class. And inside this class, we need to pass the class name. So inside this place, this is the class name. So I will copy, remove here, visiting a tail. Now if you go inside this table, let's sort by key into descending order. So inside this table, the last column with di, di called 100. So if we go and pressing Enter database sitting completed successfully. Now by the help of this class, actually we had done one more row entry inside this table. So if we go and load this table. Now as you can see that via getting once you know one ID with the new entry. And this is by the help of CDO file. So far this realization guys, thanks for watching and have a great day. 9. What is Middleware, Types & Use?: Hello guys. Welcome to the course of Laurel eight, APA dapper Turiel. This is Part 8. Inside this week you will see the concept that is, what is a middle wheel and what are its types. So first of all, we'd understand that what is a middle wheel? So if i back to slide, so let's say that we have a lateral application. Inside this application via processing thousands of FTP request. Inside these request, some are valid and Selma and valid. Right now, there is no protection barrier, means all valid and invalid HTTP request coming inside this application and gets processed. But now DID is the concept of middleware. Middleware always comes in between as HTP request and application. So middleware, Xist, some, we'll add the situation. It means when any SDP request come inside this application, it must pass through these middle wheel. So v have three types of middleware inside libel. The first we have global Mitchell will. The second rehab group, middle veal, and the third we have called route we deliver. So what is the difference between these? So if I write the types, let's say we have the first call, global. Next we have called Doug group. And finally we have called the route we deliver. So global, the word indicates that the middleware, which we will create automatically applies to entire application. Inside this application, suppose we have thousands of rounds. So when you create any middle-level which is global than directly, this global middle view automatically applies Thousands of routes what we have inside this application. Now what is group? Let's say that we have thousands or route, but we don't want to apply the middleware concept inside each of the routes. We've want that we want to specify a group of routes. Let's say we want to apply route means middle veal only on 20 specific routes. So what we will do simply, we will create a group of 20 routes. So if I write group of 20 routes for an example, and inside this route simply will apply this group meetings via concept. We'll create a middleware. Got middle will be applied only for these 20 routes. But then we'll create a global middle. We'll automatically applies to all routes. What we have inside the application. Now what is route middle? We'll van relates to that. We have 20 routes inside application and we don't want to apply, let's say to all the roles to a group of routes. This time, we want to apply the concept of middle. We'll only a single specific route. So in this situation, we'll use route midlevel instead of using global and group middle wheel. So when we create a middleware inside llamas application, we will use PHP addition command. So inside route middle wheel, we apply only on specific route. To create a middleware. We will use PHP addition command. So if I battery terminal, here we have the setup called hypha EPA. Now when we type the command called PHP addition, we should see inside may command pilot. Here we have the make command palette. Now inside this valid, you will see a command called make middle of your disk command will create our new middleware class. So when we create any middle wheel, it will go and is 2 inside this app. Inside this app we have ACDP, and inside this ACDP we should see our middle of your photo. So by default, when we install application, by default, all these middle views by default available. So when we create our own middle will automatically it will go and store inside is fooled or so after creating any medial view, we need to configure. Or we'd tell this larval application that we have a middleware and v to use that. After registering that medulla, we'll, later on we'll decide that that middle wheel, a global route or group middleware. Because vile creating any middle view by the help of making middleware command, there is no flag, there is no specific syntax to specify that. Which type of middleware actually we are creating. The whole depends on the registration of that middle V0. So which file we use to register Mitchell will simply be use cornell dot PHP. Nine site is PHP. We will raise to the middle, we'll, what we'll create for this application. So now as you can see that kernel is a class. And inside this class, we have first as an array protected middleware variable. And this middle area represents our global middle of years. So when we create a global medial view, or simply say our medulla for this application when villages. So inside this array, then that middle we'll automatically get applies globally to entire application. Because this is an airy which indicates the registration of global middle. We'll, now if I scroll down here, we have the group middleware. So what we will do simply be to create a group, after creating a group, van villages to any middleware inside that then that material. Automatically applies to a specific group of routes. This is all about our second type. Now if I call tone here we have the third type and as final, that is out we deliver. So when religious to any medial view inside this array, then that middle we'll only applies to a given specific route. Now the question is, how can we make a group? Or let's say how can we apply only for a specific route inside this application? So let's say that we have a global Middle, Rio. As I told you, that global middle will automatically get applies each and every route of this application. So simply for group middle wheel, if I go inside these routes folder, VIP taught PHP. Now for the for our group middle, we are simply what we'll do. We will create our group, so Route group. And inside this, free to specify the middleware key. So here we have middleware next week to make an array. And inside this Retail that this is my middle of view. It means heavy to pass the middle, we'll group name what we create inside this kernel dot PHP. Let's do that via a string R group middle. We're simply, we will create our register inside this array, and this is the name of the group. Simply need to copy and paste it here. And next, we need to make a callback anonymous function. And simply very religious to any number of routes inside this callback block than those routes will be protected from this medial view. This is called group middle. We'll now what is route middleware? Let's add that here we have our specific route that is sample. Now what we want, we want to protect this route for my route and delivery, or simply create a middle wheel. And I'll just throw by the help of this route medulla variable venule create energy. So inside this array, simply need to copy the name and go heel lifted that fear protecting this sample wrote, simply need to type the middleware decision method. And inside this method, we need to pass the name. So simply by specifying the name of middleware inside this medulla method via telling this application that this route is protected. Route middle V0. So this is the overall concept guys, that is, what is middle wheel and voice your site and how can we use the middle years inside lineup application 9 side. Next video, we will see a concept of Route group as well as route prefix. So far, this realization calcium for watching and have a great day. 10. About Route Group & Route Prefix: Okay guys, welcome to the course of Lalit EPA database tutorial. This is Part 9. Inside this video, we will discuss all about the route group and route prefix in level. In the last video, we had seen some concept of medial view. Inside that video. Also we had discussed all about group medulla. So how to create a group of routes? Already we had discussed inside last feet you. So if i back to slide. So let's say that we have an application. Inside data application, we have several types of admin panels. And inside those admin panels, we have a set of different types of routes. So for example, let's say we have an admin panel and these are few weeks, few routes of data admin panel. And he'll also, we have the second admin panel that is focused on and inside this customer module, we have few routes. So as you can see here inside these routes, here we have admin, forward slash, admin forward slash, admin, forward slash. It means we have three routes in which the prefixes we have called admin forward slash as these routes indicates that these are the routes of admin module. And also we can see that the same controller has been used while calling all these routes. So is this the better way to declare all the rows which have a common prefix? No, it's not. And we can use the prefix concept so that we can create a group and which we will specify the prefix like admin forward slash and insight callback function. We will specify all the roads. What we are seeing here. Nine site is customer module. Also, we can see that we have a prefix, something called customer for its class, customer forward slash and customer forward slash. Inside each of the route, we're using the same controller called customer controller. So for this also will create a group. Inside that group, we will specify a prefix called customer fourth class. And inside that callback function, we will use all these routes. So after going read these routes van, we open our application into the browser. So for this admin routes, how can we open into processor as TDP? Here we have 1270 dot v1. This is for the localhost, 8 thousand. Here we have 8 thousand boot. And after that, we should have the admin prefix unless it for the first child that is create hyphen users. So copy and paste. This is not as compositional brittle. This is cool alone. So this is the first URL. What we'll use to operate with dysfunctionality. Now, if you go and copy to base two more times, this is for list users. So if I copy, paste here at DTU user, copy and paste to you. So as you can see that inside these URLs, we have the common free pigs as admin forward slash. Now we're going to see inside the slide that what is the better way to create the prefix droughts? So if you go inside this tab, now as you can see that this structure and this structure of routes non-modified into some way. Like here we have our route prefixes, the matter inside this method via writing our prefix name called admin. Here we have three times and this time we have only a single time. Now inside this we are creating a group. Group indicates that group of routes halted we had discussed in the last video. Now inside this callback function, we have three different routes, as we can see. But this time only we are writing a prefix only for single time. Now we can access all these routes. And what we're seeing here in the same way inside this configuration as well. Now here for the customer routes, route prefix, here we have the module name, or let's adopt prefix name called customer. After that, here we have a group. And inside this group, via writing our group of routes. And in the same way, we can call all the routes. What actually reuse the calling functionality for these routes. So if I go back to Project Setup, coincide this bip dot PHP life I type wrote going site that we have a prefix method. Simply reiterate the prefixes. Now next, we need to use group. And inside this group, simply we can create a callback function. And inside this callback function, we can create our group of routes inside that. In the second alternative syntax, simply literal wrote. We will create our group. And inside this group, simply we can make an array and we can till that prefix, readwrite the prefix name here in the second way to create that callback function. And we can write all the roads inside that. These two syntax on exactly same. But inside this case, VIT prefix in front of a group. But inside this case, we are not using prefix method but rewriting prefix keyword inside this array. So this is all about route prefix enlarged L. Now what is route group? All did we had discussed that when we are creating a group in which fear grouping multiple routes into a single block. Those conditions or those situations when we create our route groups is known as group of routes or route groups of application. So he'll inside last feet you already, we had discussed that if suppose we have a group of routes and when we want to apply the middle, we'll simply, we can write all the routes inside this callback function. And if v1 to apply any group metal view simply instead of prefix, Let's type middleware creating array. And here we need to pass the middleware name while we have created this array because we can protect a group of rows by using multiple middle viewers. It means a group of routes, or simply say, a single route can be protected from fun or more than one middle wheel. So here inside this group, the middle wheel we have applied, that is first middle wheel. If we have the second middle wheel. And we want to protect all these routes of this group by the help of this first middleware and second middle view, obviously we can apply here. So if I back to slide, so this is all about the discussion of the second slide. Now in the next slide, here we are creating a group of routes. And inside this group are routes simply, we are applying the middleware called first, second on these routes. Now this time we have another syntax. If we compare this syntax from what we had seen inside this with dot PHP is something different. The difference is that inside the syntax via using Meteor method, but inside the syntax we're using group mattered. But inside this group method, we're using middleware as a key and via passing, all the middle viewers syntax is different. But the US and the consumption of all these methods will be exactly the same. So this is guys, how can we use Route group and prefixes and Lanval? Not from the next video. We will use the development of normal APIs. So far this session guys, thanks for watching and have a gritty. 11. Application Installation & Settings: It's vital Lucas of lambda eight, EPA data Turiel. This is Patton. Inside this video, we will start all about EPA development from first trade. Now inside this first phase, we will see set-up and application settings. Also we had discussed inside introduction video of this course that is, in the first stage, we will create the normally APIs without any authentication. So if i back to slide. So normally this is our API development phase. When it means without any authentication, we will create normal APIs. As we know inside lateral, we have the Alpha level authentications as JWT, passport and sanctum, but we will use these authentications in later videos. So inside this video or inside this first phase of EPA development, we will use or employees table means we will create a migration model. So we will have our employees table inside got employees table will have the columns as ID, name, email, phone number, gentle, and age. So basically, we will install the employee's data inside this employees table. So for this first phase of API development, you will have the APIs as yet employee update employee list employ as less, let's say delete employee. So inside this video, this is our first part of this API development phase when so we will do operates at setup as well as we'll do some application settings up two last video, we had seen the, all the basic concepts. What do we use inside this course? So to create a lateral project, simply, I will copy this composer command. Copy that back to terminal. And currently we're inside this lateral folder. So I will simply based on the tail and let's say that this is EPI phase when this is Prozac name. Sir, what I will do is simply press enter. It will take some time to install this folder means level it's at. And successfully, as you can see that Prozac has been installed. So if I go back to folder structure, here is a folder called epi phase 1. Here are the files and folders. So simply, I am open this APA phase 1 Present into VS Code. And here it is. Now next way to connect this application, print the database. So if I back to browser, Let's open up all about my PHP, my admin login with the admin credentials. Click here databases. Let's create a database with the name something EPA phase one. So if I copy heat database created right now there is no table. Back to editor to connect with the database, open up the file called dot ENV. It is stands for environment variable files. Now here inside this, as we can see that we need to pass our database connection details. So database we have called API fees when in my case the username is admin, and this is admin add 123. It may be different. In your case, this is my PHP, my admin, username, and password. So successfully now via connected with the database. Now let's create a controller which is going to handle all the operations of EPI. If I back to terminal. First of all, it's clear this console CD EPI, film. This is the full to what we had installed. And let's say that we're going to create our controller. Right now. This is, application is a fresh installation of level. So what I will do, let's say that inside this folder at db folder controllers folder here we have controller dot PHP. So what I will do simply due to our all APIs or to store the EPA controller will create a folder. This controllers folder. It means we will have APA folder here. Inside that folder, we will have EPA controller dot PHP file and all the operations. What we had discussed like create, read, update and delete API, all those methods we will place inside API controller dot PHP file. So if I pack the terminal, let's use the addition command to create controller files of PHP, artesian mic controller. And we want or EPA folder inside controllers folder. So EPA backwards class. And inside this we will call it as the finance EPA contour toward PHP. So if I copy the whole command, what I typed heel back to slide, basting a tail. And this is the command, what we have used. So if we go to terminal, grass enter controller created successfully, back to editor, go and reload. And I think that the syntax actually we have used to create API controller inside EPA folder is not correct because this time, instead of getting folder inside it, we are getting actually EPA. Epa can too low. So first of all, it's delete that match terminal again. And the same command we're going to use, but this time we will use the forward slash. If I back to slaves, only what we had done. We have used this forward slash here. Now save the changes batch terminal, press Enter, controller created successfully. Back to editor, go and dilute the secondary structure. Now as you can see that inside this app, as TTP controllers via gating or EPI folder. Inside this folder we have now our EPA controller file. So inside this controller file, we will write all the methods. Which is going to do good API, list, API, delete, and update API. So first of all, it's created those methods first. So public function, create employee because we're going to move in with the employee example. So here, if I write a single line comment that is preheat EPI. Now next, read to create another method is something called public function, let's say leased employees. If I write one line command again, and this is L2 API. If I scroll town green to create another matter, Let's say public function, get single employee. At, if I type again vanilla incrementally, it's a single detail EPI. Now the next two methods we want something update API as well as delete API. So let's a public function of the date employee. So here's the command call. This is up to date EPI. And the final API we want, or the controller inside this controller file, that is for the delete operations. So public function, Let's delete employee. And again when two type one line command, that is, this is something delete API soon now inside this API controller, these are the EPA is going to create something create API, list API for sewing or displaying single detail of employee. Update. Api has less delete API. Now next, we're going to pass some parameters inside these methods. Like for this create employee, what parameters we want. So while creating employee VIV want the request instance. So here we have, we're using Requests class. So I will pass it here. And we will use request instance. So when we hit this, EPI means when we hit this mattered simply, we will pass our body parameters as well as the header section. So how can we access those values from request by using this request instance? So simply we do use inside this mattered. Now next inside this list employees, we don't want any request parameters because this is the API. Simply it will display all the employees what we have inside our table. Now next here we have guests, single employee. So he'll what we want. So inside this good single employee API, simply read to pass the Employee ID. And by the help of data employee ID, we will describe the data from table. So simply he'll read to pass the ID nas called town. Here we have the update employee. So for the D TPA, what we want, we want the updated data inside our request instance means requested body parameters as well as the id value y ID, because on the behalf of IT value, you will update data. So inside this update employee method, we need request. Here we will have the request instance. By the help of that, we will read all the body parameters. And next we need an ID value by this ID, because by the help of this ID value, what we are passing here, we will update our table data by the help of requests body parameters. And finally we have delete API. So for the delete employee, we need only the employee ID. So here we will write the ID. So these are the parameters, what we have passed according to need inside all these ABA methods. So in the next video, we will create a route model and the migration file. So for this video session guys, thanks for watching and have a great day. 12. Route, Migration & Model Settings: Okay. Vulcan glucose level eight, EPA data page Turiel. This is pattern 11. And satisfied you will continue all about our EPA development phase when and inside this video, we will do route model and migration settings. So if I back to slide. So here in the last video, we discussed that for the EPA development phase when we're discussing over this employees table, inside this employees table, the columns will have called ID, name, email, phone number, gender, and age. So inside this video, first of all, we'll create a migration. That migration file basically creates these columns. And in the next we will create some routes. And inside our route configuration file, we will use GET request type, post request I PUT request type as well as delete request die also will do model settings. So a step-by-step, all these things we'll do inside this video. So first of all, V to create a migration file. So batch terminal. We will use artesian command to create migration file. So PHP addition, it's a meek migration and we'll use create employee table. So if I press Enter. As you can see here, migration created successfully back to editor, go and reload database migrations. And here we have our employee table. So V1, the table name, as per the lateral naming convention, that table name always be plural. So we won't make it as employees and employees. So here, by default, the columns we have called IT, which is auto-increment primary key. Next we have the timestamp columns like we have created at and updated at. So as we had discussed, that we need only these columns. So ITV God. Now next we need to create these rest columns. So back to editor. Let's say that table. Now the second column we have called, if I go here, this is name. So back to editor. Read to pass name. And we won't let say the mean values should be Von 20 characters in land. Again, if I copy this line based two more times, the second one we want for the e-mail address. So if I copy back to editor, this is for email address. Let's say the e-mail values should be 50 characters in land. Now next, we want something for numbers. So if I copy, go here, this is phone number. And we want a phone numbers should be 25, cactus and land. The other two columns we have called gentle and age. So for this gentle vivo code enumeration datatype, because inside this case, we have only few options of level that is male, female, and those otherwise the east column suit contain the integer value. So back to editor. Now, if I go here, Let's table. We have for the enum type called inner method. Inside these two false value, we need to pass the column names or the column name we have called gentle inside Second, Peter make an entry in which we will pass the allowed values. So we want that inside this column, we have the value either it is male, female, or others. Now next, the final column we have called the eat and eat is going to contain in teaser value each and it is unsigned value. So successfully now we have created the structure or the schema of employees table. After creating migration file next week to migrate inside our database, superconductor mineral, simply type the command called PHP artisan migrate. Now if I press enter, it will go and join all the pending migrations and create the table inside a database. If we go here, this is our database. Click on its structure. And as you can see that by default, these all tables generated by a lateral. But here we have our custom table called employees. And inside this employees table, we have the columns as name, email, phone number, or gender, age created at and updated at. One more thing, we don't want these timestamps value, so we need to remove that. How can you remove back to editor? And remove this time stamp method here? Again, when to run. So back here, let's have PHP, artisan migrate and simply type the flak old Refresh. So if I press enter, this command will roll back all the tables and migrate again. So if I go here, click on structure. And as you can see that the timestamp values now removed from employees table. So after creating table, now next we want some route configuration to create a route or before routes. Let's create a model. So this is employees table fever want the model. And as per the naming convention, models should be singular. So we need to create employee model. So if i back to terminal, first of all, it's clear this console, we will use the addition commands. So PHP, after she leads a meek model and we need to pass the model name. So the modelling, we want something employee. Now if I press Enter model created successfully, if I backed editor. Go and load this directory structure. So we will get the model inside this app models folder. And here we have employee dot PHP. Now inside this file, inside this glass file, we will configure some member variables. Little the first, Something protected. And the T-bill we're using for this employee model is something employees. So if I copy that table name, coherence, that is model. So this is the table view using and one more property that is fillable. So fillable. Why we use this friable property, Hill, freewill property, law Assignments, mass, mass assignments of all the columns. What is assigning a tail? So if I write its name, e-mail, we have something phone number, gender and age. So when we assign the values via model to all these columns to insert a new row inside table. So this fillable property to allow mass assignment to all these columns. So that's why we are using fungible property here. So successfully we have done two settings, one for the migration and second model. So if I go inside for the route configuration inside routes folder, as you can see, we have a file called EPA dot PHP. So when we create any EPI inside lateral, all the API routes should be configured inside this API dot PHP. And when we call this venue called all the routes by default, API prefix pseudo be added inside each of the route. So let's create road TO. So here I will call it as EPI phase fun. And inside this, we want our routes. So in the last video, if I close these two files, open up our controller file. That is, we have created API controller. And inside this controller file, look at all these methods. Create employ, list employees, cigarettes, single employee, employee and delete employee survey to create route for all these methods back to EPA dot PHP. So what, what is the request type for all these methods? So to create employee, as we know that we will send some parameters inside the body. So we will use post request I because VM to send data. Here we need to list out all the employees what we have inside, inside our database table. So for this case, we will use GET request I Akin. Here we are getting the single employee detail by the help of this employee ID. So in this case, we'll use GET request types, so it should be get dy. Now next, inside this update EPA method via sending body parameters as well as update ID. So it should be PUT request I. And for the Delete, if I close this file because I have pressed Control as Hill. Now for the delete API vivant delete request I saw on the basis of all these methods type, we need to create EPA rows inside this EPA dot PHP. So if I save this file first, go inside this API dot PHP. First of all, we need to load this controller. So let's say Hughes EPA can too low. Look at the part via getting API controller from controllers folder and EPA food. Now if I go here, let her out. We will use GET request type. And the EPA route is something let's say list employees. Making an array. Inside this leads the EPA controller. It's a class. And here this API means that VM to list all the employees. So it will call list employees mattered. So copy the method name Qu and paste it here. Now next, if I copy pasting it Hill akin via using GET request type, but this time, this is for single employee. So here we will have single employee. And one more thing, we will pass employee ID into URL. So here IT value will pass. Inside this case, we'll use the method as get's single employee. So if I copy, go and paste it here. Now next, if I copy this route, go and paste it here. Now nest inside this case we are going to use post request I. And this is, let's say add employee. For this route, we're using EPA controller and the matter will use call heat employee. So if I copy and cv T0, this time we have used post request I. Again, if I copy pasting it heal. And next, we want the route for update employee mattered. So we're using PUT request types. So he'll instead of f22, lets make it as PUT request tie. The route is something instead of add. It should be update employee. And one more thing inside this update employee, also via passing request, via parsing request variable to get ax over body parameters as well as via passing update ID. So back to api dot PHP file. And inside this route, we will pass our employee ID. On the behalf of this ID, we will update data. Now it will use EPA controller. And inside this update employees the mattered. Now next, if I copy, we need to create for the delete employee. So this time we have the request type as delete. The route is something let's say delete hyphen employee inside this method, as we know that we need to pass the Employee ID. So here we have the employee ID via using EPA controller. And the mattered in this case, in something delete employee. So successfully guys, we have configured our routes. We have configured our model as well as we had done the migration. Now from the next video, we'll start API development that is forced API call create API. So far this video session guys, thanks for watching and have a great day. 13. Functions of Create API: Guys, Falcon to Kusto flower eight, Turiel. This is part of the Twelve and satisfied you will create heat API. So if i back to slide, in the last video, we had done the migration score employees. And for this table we will have the column called id, name, email, phone number, gender, and age. Nine sites video. We will create an API by the help of that, we will create, call it civil add employees inside table. If I back to editor. So this is the route we will use to create employee code, add hyphen employee. Now vile calling this route while calling this API v2 pass some variables, only see some body parameters by the help of that, we will create origins to employ inside table. So we will get all the values from body parameters by the help of request instance. So here inside this block, because this is the method to create our employee. Now inside the split employee method, first of all, the first step we have to do validation. Next field to create data and finally send response. So the first state that is validation literary request, we will use validate mattered. And inside this validate method will pass an array. And the parameters we want that is something name, e-mail. Next we have called for number. Gender and age means all the needed parameters means all these parameters are required. So we need to pass our validation rule. So let's say that the name field should be required. If I copy this, the email fields would be required for numbers should be required, gentle and each apart from this required rule, also, we have the rule for email validation. Like what we have passed. The value for this email address is valid e-mail or not. Also, we have the rule for maximum land and minimum land. Also we have the rule for integer value or means to find that the value we have passed inside this age isn't in teaser, our string value. So we're not going to discuss about all these validation rules. We are taking only the required for validation rule for all these filled inputs. So this is what we have implemented all about validation. Now next, after validation way to create data and save into database. And one more thing for this e-mail will use two more rules we want for the valid e-mail, cold email. This property, this validation rule, is going to check that the value we have passed is valid e-mail or not. And the third, that is unique. It means via using employees table. And we want that email address we should enter for the first employee is not repeat suit for the second employee. So the e-mail address should be unique. Throughout, inside this employees table. So these are the rules we have applied for this email field here. So first of all, we need to load our model. So let's say use employee model. So we have now noted our employee model. So by the help of employee model, we have two options to create and save data inside the database table. The first is all about our safe mattered, and the second we have called a create method. So we will use safe mattered. Go here. First of all, let's create an instance. So employee knew. And this is all about employment model. Now next, we need to assign values. So employee, we have the name column and we will get the name value from the request is something request name. Again, if I copy paste few times, next field we have for the e-mail address. So if I copy, this is the T-bill column name and this is the requested parameter. Next we have phone numbers, so copy pasting material. Next we have gentle. So this is the name of the column and the gender value will get inside this gender. And finally, we have the IJ, so copy and paste successfully. Now we have created an instance assigned all the values. And finally, we will use the save method. So let's employ and save mattered. If, suppose, if we are talking all about the create method. So inside that syntax, what we will do employ this is our model. We will use the get method. And inside this create method passing an array and inside this array simply be to write our column name and a value like request and name. We'd repeat this step for all the columns. So this is the, another alternative way. But for this video, for this EPA view to use the save method, so I'm going to use that, remove that. So here we had our first step implemented call validation, created data, and finally creating employee when to return a response. So let's return response. We'd return the response JSON format. Let's state this equals to 1 and message. Let's employ preheated. Successfully, associate the scenes. Now successfully, we have created our first API that is Create API. So too does this APA back to post man. If I back to EPA dot PHP, this is the route. So if I copy free to start development server, solicit BHP, artesian, serve. If I copy this URL, so simply I will copy, go to Postman pasting it here. This is our local host. Request types should be paused. Hadrons. We need to pass here, let's say content type application, json. Also we want, let's say Accept application. And it isn't. So these are the two things like Content-Type and accept via passing inside this header, Goodbody, select a row. And inside this, now inside this 40 will pass our parameters into this JSON object. So we need name field, we need or e-mail value. We need of phone number. And the two columns also we need for the gender and age. Now, inside all these fields, let's say the value we are passing, this is our first employee. Here we have the e-mail address of data employee phone number is something that dummy value I am taking Hill. Next we have the gender and age. So let's say that 30 is the age. So this is what we are passing inside this row. And inside these headers, we have selected Content-Type and accept 21 more thing. We need to add the route here because this is only for the localhost right now. So go here inside this EPA dot PHP simply I will copy Gu hill as we are using the route from EPA dot PHP files, EPS would be prefix. And after that, this is the route. So if I copy back to slide the URL via using to create the deta a, something, something like this. And the parameters that we have passed here go to body. If I copy back to slide and pasting it here. So this is all about genes and upset. What we are passing back to Postman. Click on Send button. And here we have some error that is called column naught phone that is unknown column updated at. And this is because actually we have removed the timestamp columns from this table. But actually we didn't call our model that we are not using timestamp values. So this is our mistake. So to correct that, what we have to do, go inside App models employ dot PHP. Because inside this table we are not using timestamp values. And by default, level model will look for all those columns as well. So we need to tell here. So let's say public via naught using the timestamps. So timestamps equals to false. All we have done, if we again go heel back table first, click on Browse, right? No, there is no row inserted. Back to Postman. Click on Send button. A keen. And as you can see that employ created successfully. If I back to browser, click on Browse. And as you can see that our first row now successfully inserted by the help of create API via unmuting. If I copy this email address akin, and we'll try to do one more entry with the same email address. Click on Send button. As you can see that we're getting out of that is the e-mail had already been taken. If suppose, instead of all these values, if we pass the null value, click on Send button. This is all about the handling by our validation. What we have added inside this adders, the name field is required, email field is required, and the phone number field is required. So successfully guys, we had done the year API, we had implemented validation. We have concrete data as less sending response. Now in the next video, we will see all about the concept of list employees. So far this realization gas and who are watching and have a great day. 14. Functions of List API: Guys, welcome to the course of law. Eat EPA database Turiel, this is platinum 13. Inside this feed you feel to create an API which will list all employees. So if i back to editor, in the last video, we had created the EPA, which register or employee inside our employees table. We had covered the steps or validation data as well as sending response. Now this time we will use list employees mattered, which will list all the employees what we have inside our database table. So right now we have created four dummy row entries. So if I backed editor In the last video, successfully, we have loaded employee model. So we will use inside list employees mattered as well. So let's employees equals to model called employee. And we'll use get mattered. So for now, if I type print our employees, safety, the change, it should be something employees. So copy and paste and keeping mind to actually list all the employees we have the EPA route as least half and employees which we will request via GET request I. So if I back to Postman, copy this route, open a new tab, paste in detail. This time the EPA route we have called list hyphen employs. So if I copy back to Postman again, list employees, here we have that GET requests type. So when we click on this Send button, as you can see that via getting the response, if I, again hoping this URL into the browser, because this is a GET request type. So easily we can open that. Now he has, you can see that we're getting 0, a collection object inside this collection upset via getting the object of employee. So here we have the 0 index. Next we have the first index. This is for the second rule. Here we have that Todd indexMin second and next we have the third instance. So what actually these are via getting from 0 index to third index, which indicates that we have total number of rows equals to four. So now we need to read into a proper format so that the EPA's would be useful. So if I back to editor, go to API controller. So instead of print out what I will do, let's return response. We will convert into JSON format. Let's say status equals 21. Message equals to list the listing employees. And also if you want to send a custom HTTP code. Also in the second value of these genes and method, we can pass it here. So let's add that V1 to send 200 status HTTP code. So simply I will pass to a 100. Otherwise by default, it will pass the 200. If we want something more STP code like 500 for 001 or something else, we can put it here. So after doing this also when to send this employee's means, this is our main data. Go here. Alice, uh, d Theta equals to employees. So if you see all these changes back to Postman, click on Send button. And as you can see that we're getting appropriate response. That is status equals to one message equal to listing employees. And here inside this data array, via getting upset, the first object we have the first row of table, and so on. So this is all about guys listing of all employees from TB. In the next video, we will see and discuss about more EPA's so forth is producing gas and for watching and have a great day. 15. Functions of Single Data API: Hello guys. Welcome to the course of larval. Eat EPA data pictorial. This is our pattern 14. Inside this video, we're going to create an API which will display the information of single data. So if I backed editor in the last video, we had completed all about our API as well as list employs API. Now in satisfied you will to over work over single detail EPI in which we will pass employee ID by the help of that employee ID, we will fetch only specific employee information. So what I will do as you know, that we have loaded employee model inside last video. So first of all, on the behalf of the employee ID, we need to check that this employee accessed or not. If it exist, then we need to return the response means the details of that employee, otherwise employee not found. So simply what I will do, let's say if employee model will put VR condition, we will check that the ID that we have passed is equals to id column of table. And we will use the Xist mattered. If the employee accessed that it will return true value otherwise employing not exist, it means false value. So what I will do return, Let's response. We will use JSON array. And inside that, let's say status equals to 0 message. Let's say employ. Let's make the first litter as capitals so employee not found. And we will return the status code, let's say 400 for now inside this block, it means to employ axis. So what I will do free to fetch the employee details. So let's employ detail equals to employ model. We will use veer method to check our condition. This is the id value and we will use the first mattered after that simply return response. Json. Passing an array. Let's add that status equals to one message. Let's say employ found. And finally, we'll add one more parameter that is data. And inside this, we will pass this employee detail. Now if you save all the changes, back to Postman, if I copy this URL, go heel back to EPA dot PHP. So via using single employments, via calling get single employee method. So we need to copy this route back to postmen. Instead of list employs. This time we have single hyphen employee. And the matter type we need to use called GET request type and V2 pass employee ID into the URL. So back to Postman. So here we have the post I equals to get regress type. And if we pass two, as you can see that inside this too, we have this employee. So when we pass inside the single employee route to click on Send button. As you can see that fear getting all about second employee detail. But van remake to do 2018 started this employee ID does not exist into our list. So in that case, if we press Send button, as you can see, that employee not found and he'll look at the status code 404 via getting. Also, we can control our status code, what we had written here. So successfully guys, This is the video is only to get a single employee detail. Nine, the next video we will discuss over update API. So far this video session guys, thanks for watching and have for clarity. 16. Functions of Update API: Okay guys, welcome to the course of larval eat EPA development tutorial. This is Part 15. Inside the sweet you freedom to create an API for up-to-date information. If I back to editor in the last video, step-by-step, we had done for discrete list and we had done get single input detail. Now this time we will walk for update API. So inside this update API V to pass body parameters, it means updated employee information as well as employee ID. On the behalf of this employee ID, what we are getting inside this ID variable, we will update the existing data by the help of body parameters, what will get via request instance. So go here inside this method block. First of all, we need to check that the employee exist on the behalf of this idea or not. So let's, if employ, we will use VR mattered. Let's ID equals 2 id. And we will use accessed mattered. If suppose employee Xist, then we will go inside this if block. Otherwise, we will go inside this else block. So in the last video, we had handled the same situation. So I will copy this masses something new employee not found. Coincide this else block and pasting it here. Now inside this if block, It means we have now employ. So what I will do, Let's employ equals to employ. We will use find method. And inside this find method, we will pass employee ID hill. What find method will do? Find mattering level basically finds the data on the behalf of primary key. As you can see here, that inside this method we have specified the column, but inside this find method, we haven't specified that this idea is compared with the ID column. Automatically this Find method will look this ID photo primary key. So after finding details, but I will do, we need to update the existing data. So here let's employ, we need to update our name value. So let's request name here. Now if I will copy, paste few more times, the second is full, it's an email. I will copy pasting it till next we have something for the phone number. Copy, paste. Here we have for the gender. I will copy and paste. And for the last time that we have called each heel. So let's adapt and unmuting while updating information. We want some form validation as well. But he'll via discussion all about update employee mattered. So this time. We're not going to implement such type of validation because violating any information, this information is either required or not. Let's adapt. We have a case when we want to update all information. But also we have the second case in which we want to update only for number. So we can specify the form validation like all the fields are required in the case of update employee EPI. So instead, what I will do, we need to take that if not empty. It means inside our body parameters if the name key exist and if it has a value, then in that situation we need to update with the updated value, otherwise, employ and name, we will update our name field with that system value. For this line means, this line means that if via pass in the name value inside the body for update, let's say for the new value. If the new value exists and it is not empty, then we will update. Otherwise, the existing value will be updated. So seen, we need to repeat for all the columns. If I copy and paste, copy and paste, copy and paste. And finally Copy and Paste. Now going to change the keys. So e-mail, copy and paste. Next we have for the phone number, so I will copy for the gender and finally for the age. So after updating information, we need to return a response that is user has been updated. So let's return response JSON method. Let's status equals to fund message. Employee. Updated. Successfully. Save all the changes. And also if you want to specify the ACDP code, we can write it here, but by default it will return to 100. Now if you go inside this EPA dot PHP, so to call this method update employee, the syntax is something update employee V to use PUT request type. And also we need to pass the Employee ID into the URL. So back to Postman. First of all, I will copy the syntax. It means the URL like localhost, EPI, single employee and all. But inside this case we have update hyphen employee. So I will copy go Hill. And let's say that by default, if we want to update 20th ID, PUT request type and 28 ideas. We know that this does not exist in our table. So when we press Send button, employee not found. But when we pass in the two value as we know that it exists. And let's say that for this second number employee ID, we want to update this name value pseudo, he'll go Hill. Hadoop us, we will pass Content-Type equal to application JSON. Accept application JSON, go to body row. And inside this we need to pass. Let's if we want to update the name value only. Vijay Kumar saying this is the name, what we have written as updated value instead of this old value. Now when we press this Send button, students equals 2, okay, Employee updated successfully. If you back to this API which is listing all the employees, click on Send button. And I think that the employee has not been updated. If we back to editor. And if you go inside the update employee mattered. Here we're finding the details, updating all the informations. And one more thing, actually, the most important thing we forgot to add using safe mattered because without save method, how can we update the information to database? So simply employ and save all we have done. So if we save all the changes back to boost man, go here, Let's update employee to. Now it press Send button. Employee updated successfully, go to the list of APIs. Click on Send button. And as we can see that the name has been updated. Now one more time, if we want to update the information of this toad number, employee ID, Let's name and gender. So how can we update? Simply go, he'll pass in blue Ids equals to 3. Let's v12 need to update heel. This is the name. And heal. We want to update the gentle. So let's a female. So on the behalf of this toad number employee ID, via updating this information, click on Send button. Employee updated successfully. Go hill. If we click on Send button. And as you can see that the name has been updated and the gentle has been updated. So successfully, guys, this is the EPA concept veal we have implemented update concept and this is we have used PUT request I. Here we are finding the employee exists or not. If we exist, we're finding all the details, updating all the existing values and saving inside our table. And if employee doesn't not exist, simple, we have the response as employee not found. In the next video, we will work over the last API of this EPA controller concept for delete employee. So for this video session guys, thanks for watching and have a great day. 17. Functions of Delete API: Okay guys, welcome to the course of larval. Eat EPA Dallas Turiel. This is Part 16. Inside this video, we're going to walk over delete API concept. So if i back to editor, in the last video, we had forked over update API and the last method and the last API we will see inside his feet you all about this API controller, all about delete API, delete employee method. So what I will do simply the symbol into check first that on the behalf of the employee ID, the employee access or not. If we taxes, then we will delete otherwise employee not found. So let's say if they employ, we will use real mattered ID equals 2 id. And we will use Xist mattered. If employee exist. What we'll do simply will delete otherwise, let's say employee not found. So if I go to the other APIs, like for the update here we have like employee not found. I will copy the same code writing here inside this else block. It means employing not found. And if employee exist on our behalf of this ID, it means me to delete that. So heal, employ equals to employ model. We'll use find method. And finally, what I will do read to delete this employee upset because by the help of this statement, we're returning or employee upset on the behalf of this IDE. So simply V to delete that employ object. And finally, we need to create our response to return response. It's not resolve its response. Json. Passing an array. Let's get status equals to one and message. Employ deleted successfully. Now save all the changes. What we're doing here simply we are checking employee access or not. If it exist, then finding the employee upset and deleting here. And if not exist, simply returning a response that is employee not found. If I back to Postman, copy this URL, open a new tab, pasting it, heal. To get the URL go to api dot PHP. Here we have delete employee and the request that given my delete type. And also we need to pass the ID means employee ID into the URL. Going to the post man, select delete request type. And the EPA route is something delete hyphen employee. So while calling this route, if you pass ID equals to Tati, as we know that this term does not exist. Click on Send button, employee not found. Now, suppose we want to delete this Tottenham ID from this list from our table. Simply pass three Hill with the delete request type, click on Send button employee details successfully. Now if you go to the list, click on Send button. And as we can see that we have the ID called fun too. And for Tottenham, ID is not deleted from our table. So this is guys, How can we can walk in the lateral EPA's? And inside this course successfully, we have completed our first phase that is normal EPA development without any authentication. We have seen the overall concept, overall scenarios like creating, listing, good single employee detail, updating, as well as the delete API concept. Now from the next video, we will include our authentication tool. Either we can include JWT, passport or sanctum, And we will implement and see that how can we work with the EPA's, with authentication tools? And one more thing, the whole goal of this first phase, what we have tablet, I will include into the resource section of this lecture. You can download the whole source code. What we have done heal from the resource. And also one last thing, if I back to post man, go heel, if I copy this URL back to editor, let's include the URLS. Well, so this is for the ADD employee. Go to Postman. If I copy this URL, here we have the URL to list all the employees. Now next here we have the single employee detail. Go here, Let's say URL, single employee detail. Next we have update employee. So I will copy, go here. Here we have the URL. And final one we have footer delete API. So if I will copy and paste it here. So from the next video guys, we will work on the second phase of API development. So for now, thank you for watching and have a great day. 18. Application Installation & Settings: Hello guys, welcome to the goose of larval. Eat EPA database to real. This is partner 17 from this video session guys for him to start the second phase of API development by using Santorum authentication. So inside this video, we will see the introduction and application satyr. If I back to slide from this video session, guys feeling to start EPA development that is fused to using sanctum authentication. Sanctum is a newly added feature in lateral from animal seventh version. So currently fear using larval eat version. Sanctum token is very lightweight due to lightweight feature of sanctum views inside single-page applications, that is, for mobile APIs. When we go V2I video inside the schools, we will see about the tokens structure. Token ring structure is very simple, due to which we will use inside single-page applications. Nine site is second phase of API development. We will take a scenario of students and projects. It means we have two tables, like students and projects. Inside this student's table, we will have the column like ID, name, email, password, and phone number. We will install the student's information inside these students table. And the second table we will have got ID, student ID, name, description, and integration. So inside this table, frivolous to the projects detail. As we can see that students will have an ID column. This is the ID we will use as student ID as a foreign key inside these projects steeple. So this is all about student information and this is all about associated student projects detail. So inside the second phase, what are the EPA's we will cover? Three will create students register, student login, student profile, logout Prozac, create Prozac list by student ID gets single productivity. And finally, we will see present delete inside this ET APIs. We will have some without authentication and some APIs need sanctum authentication. When we do student related information like register, login, and profile, it will go and operate with these students table. But when we do our projects related task like Prozac, prozac least by student ID, Prozac detail present, Delete. It will operate with project's table. So we will see each concept of fields to EPA dopant using sanctum authentication from this video. So first of all, we need to create a lateral setup as what we did for the first phase. So if i back to fool the structure, this is the photo, what we had created in the first phase of development. If I back to terminal, let's create a second phase means the second development. So if we type the composer command to create lauryl protect. And here's the command, composer create hyphen. Hyphen, hyphen preferred. This lateral, forward slash lateral and hearings EPA fees when. So this was the command actually we had used in the first phase project setup. Now we will change called EPA fees to press Enter, we need to wait for a while because Prozac, prozac is now settings are now successfully. As you can see, that product has been installed. If I back the folder structure, this is the folder of art we have created. Now I'm opening this project into VS Code, and here it is. Now first of all, we need to configure database. So open a file called dot ENV. First of all, we need to create a database and sad database connection details right here inside this Dadi and variables. So open up Chrome browser. If I type localhost PHP, my admin logarithm, the details of admin credentials, click on Go button, click on Databases. And let's say EPI phase two. If I copy the database name, click on Create button. Database created. Right now there is no table. Back to Editor database name. This is the name and admin details in my case, for my system, these are the details. In your case. It may be different. So successfully guys, now inside this video, we had seen the second phase of EPA development interaction as well as application setup. From the next video, we will start the development inside this phase two. So far this video session guys and for watching and have a gritty. 19. Migrations Setup: Hello guys, welcome to the course of larval eat API data page tutorial. This is platinum 18 and satisfied you will see migration settings. If I back to slide, as we had discussed inside last video, that in the second phase of EPA development, we need two different tables. One table is to store the students data and the other wills to projects data. For this is too unstable. We need the columns ID, name, email, password, and phone number. And here are the columns for our projects table. So to create table, we need migration files. So to create migration files, batch terminal, BHP, partition, mic, migration, and V to create it's a students table. Now if you press Enter the forced migration created successfully, PHP, artesian, let's say meek migration. Here we have projects table. Now if you press Enter the second migration created successfully. Back to editor. Dilute this table is structure means folder structure to see all the migrations coincide database migrations. And inside this folder, we can see that these two migrations we have created. Now if we click on this file, by the help of discrete, is Turin stable via creating students table. By the help of this create projects table class via creating projects table. Now next, we need to set our columns what we had discussed inside slide. So let's see all about for these students table. So for the students table we need ID, name, e-mail, password, and phone number. So if I back to editor by default, this ID method is going to generate id column, which is a primary key, as well as auto-increment. And also we don't want this timestamp value, so I will remove that table. We need to take the string for the name value, let's say 120 cactus and length. Next we have the column as for the e-mail address. So here we have email, let's say 50 characters inland. Table, string. This is for the password field. Let's say it will be 70 characters in length, because inside this password field, privileges to has value and the highest values, basically long text in comparison of plain text. So that's why we are taking 70 characters in land. And finally, for these students table, we need one more column data is phone number. So go hill. If I copy the last line pasting it here, led to the column name we have called phone number. And we will put 25 characters in land. So all we have done with these students table. Now the same thing we need to do for the projects table. So click on this file. Go hill. Again, inside this table, we don't want any timestamp values. So I will remove this. We want student ID. So let's entheseal column names. We should have called student ID and it should be unsigned. Now next, we need the name field. Name, field indicates all about project name. It is 150 characters in length. Next we want all about description. So we need to tack takes as a datatype and the column name we have shoot something, description and finally, dilation. So table, let's say in TSO column name we have called duration. And inside this duration we will install something. Let's 3, 5, 7, any integer value. So here now we are set the students table as well as project's table. One more time. If you review the columns, student ID, name, description, and duration. Now to migrate all the migrations, what we had 10 back terminal BHP, artesian migrate. If I press Enter. As you can see that the migration now running and migrated all the migrations. If I back to database, go and load this EPA phase 2. Here we have our students table. If we click on the table name GO TO structure. Here are the columns. And if I go inside projects table, inside this table, here are the columns. Now in the next video, we will walk over model and controller settings step-by-step. Now we had seen the migration files for these students table and our project's table. So far this utilization guys, thanks for watching and have a great day. 20. Model & API Controller Settings: Okay guys, welcome to the course of larval. Eat EPA to real. This is Pachamama 19. Inside this video, we will see the concept of model and controller settings. If I back to editor. In the last video, we had created two tables called projects, as well as students. Now we need to create models. The models are those files which is going to interact with these tables. So to create model, we will use addition command. So packed terminal, BHP, artesian make model. And we'll create first, let's say student model, as per the naming convention. Also, we had discussed earlier that the table names suit be always plural, but the model name should be singular. So PHP attrition make model. And for the students table, the model we should have called student pressing Enter model created successfully PHP artesian make model. And for the projects table, the model we have called Prozac. If I pressing Enter, now we had created all to model files. If I back to editor, reload that tie to structure going inside App models. And here we have present model as well as student model. So if we click on this student dot PHP, we need to set the table flags. So let's protected table via using Student's t will for this student model or by default, this module, we'll pick this table name. Now next, as we know that in the migration file or inside our database table, we are not using any timestamp columns. So inside this model, we need to configure all we need to tell that we are not using time stamps. So let's say public timestamps equals to false. And here we need to specify one more property that is feasible for the mass assignment fillable inside this array, we need to put the column names of students tables who name, email, password, and we have called phone and the SKU number. I will copy all these settings. What we have done with this student model, go inside this set dot PHP and pasting tool settings here. Now according to the need of this present model, genes, the table name called presents, the column name we have called the Prozac name. Here we should have the student ID. Next we have description. And one more column we have called duration. And also inside this table we don't have any time standard value, so it's all okay here. Now we have done successfully the settings of model of this student as well as this Prozac model. So after doing all these modulus turf, now we need to go and take a vote on the actions of controller file. So to create controller, again, we will use go inside this app folder as HTTP folder. Inside controllers folder, we will create a fool to call EPI. Inside this EPA photo, we'll create our needed API files. So to create EPA controller files back terminal, BHP, addition, Mic, come to LA and we need all the API controller files should be pleased inside or EPA fooled. So here, EPA, EPA, next few to pass. Let's say first of all, student can to law or simply we will call it as odd controller. Let's say we're calling it as student. Pressing Enter controller created successfully. If I back to editor, go and dilute. So now inside this controllers folder here we have EPI, and this is all about student controller file 09. The same we need to create project controllers. So PHP partition meek going to low. Again be to create the Prozac controller inside EPA photos, EPA, Lisa preserved. Come to LA. If you press Enter controller created successfully, go and reload this. And now inside this EPA photo, we have two files. Inside. This is twin controller. We need the G string method, a login method, profiling method, as well as our logout mattered inside this Prozac and too low, we need methods for creating a project listing or Prozac on the basis of student ID and project ID listing all the projects on the basis of student ID, as well as we will see Prozac deletion. So this is the video to demonstrate all about model settings and creating our EPA controllers. In the next video, we will walk over the methods of this student controller as well as Prozac controller. So far this video session guys, thanks for watching and have a great day. 21. Installation of Sanctum Package & Settings: Okay guys, welcome to the course off laterally API data Turiel, this has partnered with 20 and scientists feed you through, we'll see sanctum packet settings. If I go back to slide. So in the last video, so far inside these fields to EPA development, we had done all about Project Settings, migrations, models, EPA controller settings. Now this time we will configure and do settings for sanctum authentication. So to install centered package inside this project, what we have inside this EPA phase 2. First of all, we'll run a few very simple, simple composer commands. By the help of those Gawande's, we can configure sanctum package inside this project setup. If I back to slide. And as you can see that I have listed all the commands. What you will see inside this feed you. So first of all, we need to install sanctum package via this composer command. Composer require lateral forward slash sanctum. When we run this command, it will install a sanctum package inside this proves, et cetera. If I back to slide, now next, we need to publish our sanctum configuration for protect Saturday. So by running this PHP are additional venture public provider. By doing these, simply, create sanctum configuration file inside our config folder, as well as public create, our migration file. So step-by-step, we will see that how can we do sanctum packet settings inside a level process? So first of all, we need to install that. So if I copy this composer command, add one more thing. All these commands I will provide into the description of this video, you can simply go copy and paste and execute inside this second phase of API development. So if I will copy this command back terminal, currently we are inside this EPA fees to pressing Enter. As you can see that now via installing sanctum package. So successfully now if we had done that, now in the next weird to publish our sanctum configurations. So if I copy this command back terminal, clear this console, putting it heel, pressing Enter. And as you can see that now we had done the settings inside this Migrations folder. It means this command has PRB list or migration file, as well as inside Config folder, we have sanctum dot PHP. So if we go inside our project setup, glued this directory structure, go inside Config folder. And here we have suntan dot PHP. This is the configuration file of sanctum authentication package. Go inside this database folder, migrations. Now inside this folder, we should see one more migration. We have reaches something. Create personal access tokens. And this migration file is created when we had done installation of our sanctum package, as well as when we had published on where this addition command. So simply copy this command because we are going to migrate the migration what we had created. So copy this command, backs terminal, pasting it here. Now as you can see that now we have created a table called reheat personal access tokens. So if I go inside this database, reload this rectory structure. And as you can see that now we have a table called personal access tokens. So in the next what we have to do, we to update a route service provider file by default when we install level setup this lane, this piece of line but we are seeing is commented. So first of all, we need to uncomment this line. So we're, we can find routs service provider file back to present Sutter. Go inside this app providers folder and inside this route service provider. As you can see that we have a line here and this is by default commented. So we need to make uncomment that we had done. Now next, we need to update model. So as you can see that inside this second phase of API development, we have to model. The first model is pointing towards this student's table, which is student model. And the second we have for the projects table call Prozac. So in which model we need to update these settings. So that model, which will be used for authentication in that model for we'll do these configuration. So as we know that for this example, the student is students table means student model is operating with authentication. It means is student controller will have the method of registration, login, profile, and logout. So by the help of student model, we will do registration and student authentication. So inside student model, we need to do all these settings. So first of all, inside student model, we need to import this has API tokens. And finally, we need to actually include this thread inside glass. So simply back to Project Setup. Close this file, go inside App models student dot PHP. So at the first step, if I copy this command, go Hill and pasting it here. And in the next VII to include that this has API tokens. So copy, putting a comma here after has factory and pasting it here. All we have done after adding these, you can see we have a red color errors too. Don't worry at all about this error. It will work perfectly. So successfully guys, inside this VQ, we had done all the settings of sanctum package inside these Landsat 9. The next video, we will create all about our API routes. So for this review session, guys, thanks for watching and have a great day. 22. Define Controller Methods: Hello guys. Welcome to the course of lauryl eat EPA data Turiel, this is partner 21 and satisfied you will see controller methods settings. If I back to editor. Now, in the last video, we had created two controllers. If you go inside App as GDP can to lose APA. As you can see that we have two controller called Prozac controller as well as student can to law. So water, what are the methods we want for these controllers? So for matter information, if you go inside this slide, these are the actually EPA's VM to create insight, second phase of API development. So inside student controller, we need our registrar method, login method, profile method, and our logout mattered. So first of all, we need to create for these four methods inside student controller. So if i back to editor, go here. Let's say public function. Simply, let's say register. Next, read to create public function. And the method for locking. After that, we need what Blake function, let's say profile. And finally matters we want inside this student controller is that public function logout. So these are the four methods we are creating inside this student controller. Let's add one line single command. This is registry API, logging API, Profiles API. And finally, we should have the lookout API. Now inside all these methods. In which method we want parameter inside our fees when developing APIs, we have seen that in some few methods, we have passed our request incense. So inside which method we want our request instance. So just think for a case, when we hit this register method, as we know that we need to reduce student by the help of this mattered. It means inside this method we will pass body parameters and those parameters contain student information. So v want the request instance inside this register methods. So here we will create the request instance. By the help of this request instance, we will access all about input values getting from body, from post man are from API. Coincide this login. Think about this login mattered. By the login method v will pass email address and the password. And by the help of this mattered for when logged in to useful to use our setup. So inside this case, also we need request instance. By the help of this request instance, we can access the email address and the password that will hit this login mattered. Now next, we will have profile method and the logout method. So these two methods like register and login needs not any authentication. It means vile calling all while registering these two methods inside EPA dot PHP file, we don't need to include actually any type of authentication. But in case of profile and logout, we need to wrap inside a middleware that is sanctum middleware. So we will discuss inside next video. It means inside the string controller, we have two matters, which, which don't need any authentication, but these two methods need authentication. Now if you go inside the Prozac controller, inside this proves that can too low. We need methods. Let's separate project create Prozac, list, single Prozac and Prozac delete. So back to controller. Let's say that public function create by the help of this preheat method, we will create our project. Now again, public function. Here we have least Prozac. So this is list mattered. By the help of this list method, we will list all the projects. Now next, public function, we will have a single mattered. By the help of the single method, we will display a single present information. And finally, we need public function delete. So by the help of this delete method, we will delete Prozac. So let's add a suffix as Prozac. So I will copy list Prozac, single Prozac and delete Prozac. Let's add one more line comment. This is all about Create Project EPI, list Prozac API, single project EPI. And here we have delete Prozac EPI. Now inside this proof second to load inside each methods. So from these methods will we want request instance? So think about this create Prozac ventricle, this method, it means by the help of this method, we're going to create present. So obviously, we will pass parameters to create a project inside body. So what I will do simply, we will pass requests instance here. So request class. And we need to create request instance. By the help of this request instance, we will treat the body parameters. Now here we have lists Prozac. So inside this case, we don't need any parameter only. We need authentication. Here we have single project. So while displaying any specific product information, we need uploads at ID. So in this case, we need Prozac ID for this delete process API also to delete any specific prozac, we need Prozac ID. So all the necessary parameters via passed inside all these methods. And one most important thing that inside this controller, as we have seen, that two methods don't need any authentication. But these two methods need authentication. Prozac and insight Prozac controller. Each methods what we have created needs authentication. It means when we use any method, the user login must be needed. Because to process any request which associated these methods needs token. So we will see in the next video that how can we create API routes? Inside that API routes register a few routes. That means that will run without any authentication. And few matters which we'll use. Our middle we'll read, takes that our token is valid or not. Let's say it going to check authentication. So successfully guys, inside this video now we have configured all the needed methods to create our APIs inside this student controller, as well as inside Prozac into law. In the next video, we will walk inside api dot PHP to configure our EPA routes. So far this realization, gas and coal watching and have a great day. 23. Create API Routes & Sanctum Route Grouping: Hello guys, Falcon glucose off laterally eat EPA data pictorial. This is our partner 22. Inside this week you will see EPA route configuration. If I back to editor in the last video, what we had done, we had simply created our controller methods for methods inside this Prozac controller and formatted inside his student controller. Now this time to use these matters, we want EPA routes. So to register, EPA routes, coincide routes. Photo, open up the file called APA dot PHP. Now inside this file will create APA roads. So first of all, we need to import our two controllers that is used. Let's students. Also we won't he Jews Prozac controller. So successfully now we have imported. Now we need to create API routes here. So first of all, we need to create biologists are out solitary route. And the route suit because via post request I supposed register passing an array inside this, let's say student controller. It's a class. And from his students. First of all is create all the routes. Then we will map the methods. Next we will have login. And finally, these two routes needs not any authentication. We can directly call. But when we use other routes like profile, logout, all the routes of proofs that we will need some authentication. So to actually wrap all those routes inside a group and inside that group will use sanctum middleware. So what I will do simply will create a route group. So group hill, passing an array, middle, we'll probably use passing an array. And we will use OT sanctum when we do the cementum Package settings inside this Prozac. So vile settings, we have odd middleware means odd sanctum with Libya. So when we wrap all the routes inside this group, it means those routes will be protected via AAD sanctum. It will take that via passing any authorized sanctum token or not. If yes, then it will go and we will able to access all those routes. Otherwise, we will get an error sending unauthenticated. We will see also how the process request in upcoming videos. So right now register and login need not any authentication, but other routes. Let's create a closer function. Now inside this, the first authenticated API it out we want something product profile. So route. It will be GET request type, let's say profile. And inside this, we will use student controller. In a seconds, we'll map them mattered. Also, we won't look out using GET request type. These are the routes we have configured via student come to life. Now next, we integrate the routes from Prozac controller. So he'll reroute, get vivo won't create Prozac. So create hyphen project. It will use the contour call facade controller. It's a class, will map the method here. And one more thing. When we create Prozac, then add the situation. We need almost request type. So if I copy this, go Hill, the next We need if if I back to the EPA list here we have Prozac create. We had done Prozac list. So inside this Prozac lead list, it will be GET request type. So here get. And this is list hyphen Prozac. After that, we need the EPA route, let's say for getting single-process that detail. And for the single post that detail, we need to set ID into URL. Also, we had them do settings. If I back to controller, go Hill. And as you can see that Val getting this single product information, we need Prozac ID. So go he'll get request type. It will be single hyphen Prozac at the URL, we need Prozac ID. And finally, Venmo mattered. We need something that is delete hyphen Prozac. So let's delete. And this time we will use delete request I studied hyphen preserved. We need to pass Prozac ID heel, and the matter will use for that, delete Prozac. So if I copy and paste here for single preserved, we need to use this method, copy and paste for list preserved. This is the method copy and paste for preheat Prozac. I will copy and pasting it here. Now, if I open all about controllers, students do get idea of methods. So here we have logins to copy and paste, copy this login method, copy and paste to get at the profile. This is the profile mattered. And next we have the logout mattered. So successfully guys, as you can see here, we have all the routes from that. These two have no authentication, but all these routes like profile, logo, all routes of Prozac needs sanctum authentication. And all these routes now protected from a group metal wheel or sanctum. And this middleware is available when we had configured and install sanctum package instead inside our data. So from the next video guys who will walk over these matters, what we have configured heal. So far this video session guys, thanks for watching and have a great day. 24. User Register API: Okay guys, welcome to the course of larval. Eat EPA database Turiel. This is our partner 23. Inside this video, we're going to create our fourth API that is, students register EPI of this second phase of development. So if i back to editor in the last video, we have configured all about EPA routes as well as these students, and they have mattered. So to create logins API v2, use this register method, go inside this method. So what are the steps we have to follow to create or destroy api fossa fall after taking inputs by the help of this request instance, we want to do some validation of those data. Next, we need to create data and finally, send response for our API. So we need to follow the same steps what we had done inside freeze one development. So inside the validation, Let's request. We will use validate mattered. And inside this validate method, we will make an array. And while registering any student, what are the fields actually revolt? If I back to T-bill, go to students, click on its structure. So we need name, email, password, and phone number. Back to editor. So we need name-value, we need e-mail value, and we need, let's say password. And for now, let's say that this phone number is an optional parameter. So first of all, we need to make a default to accept null value. So we interchange the migration file. So what I will do back to editor, go inside database migrations. Here we have students migration file. And we want that the phone numbers should accept the null value. So we will use nullable mattered. Now we need to update this migration and load again to this database table. So how can we do back terminal simply, let's say BHP, artesian migrate and we will turn refresh suppressing Enter. As we can see that while running this command first, it roll back all the tables and then migrated all the tables. Now if you go inside this structure, and as you can see that the phone number is not accepting the null value. So we need to create this field as an optional. So v are not going to pass phone number inside this validate. So what I will do simply let say this mean value should be required. Now if I copy this rule, go inside for this email address, mil values would be required and for the password, passwords should be required. The rules I will attach for this e-mail, passing a pipe symbol. Unless the email, this rule is going to check that email address is a valid format or not. Next, I will take that uniqueness. So as we know that via storing all the data inside students table. So from this table, I want that email address of each specific rule should be unique. So all we have done and inside this password, I will add one more rule, something called confirmed. These rules means that when we will do is Students registration, we need to pass the parameters as name, email, password, and password on the scope conformation. Because in this case we're not adding password and the scope confirmation parameter inside this validate array. Instead, dynamically we will pass inside body parameter if you don't pass password and the scope conformation with the same value, what we have inside this password field, that it will give an error something the password confirmation field should be required to. Now successfully, we have implemented all about the validation rules. So if let's say that all the validation rules passed by our input values. So after that, we need to create the values. So for that, we need to import our student model. So USU student model. Go here, create an instance. So let's say student equals to new student. After that student, we have the field inside our table as n0 equals to. I will copy paste few more times. After knee we have e-mail address. Next we have password. After that, we have formed under SKU number. So total fulfills. We have again back to DB, check here. So we have fulfills. We don't want this extra. So get rid of that. And here inside this name for relaxes the new value via this request instance. So here we have the name value. If I will copy go heel. This is for the e-mail value. Novae have heard of password. And finally we have for the phone number. So let's say phone number. And as we know that a phone-based optional value. So first of all, we need to take here that is each set. It means this phone number key alpha liberal or not, if it is available. So in that situation, we will pass this value. Otherwise, it will go with the empty value. And one more thing that while registering user amines, student inside students table, we want password sued been hashed value. Right now we are getting this password value in plain text. So first of all, we need to convert into hast format, so forth that we need to import the Jews. Hash. It is coming from facade, go Hill. And simply, I will use hash. And it's unique mattered. So automatically, after taking this input password value, which is a blink tags, it will convert into a hast format. And finally, after doing all these stuff next week to let says student and see if. So what I will do, this is for the validation and this is for the creating data. So if I got all these courts from here, go after this command and pasting it here. Now next, we need to send a response. So let's return response JSon, making an array. Let's status equals to V1 and message. Let's say student registered successfully. All we have done. Now we need to test this API, what we have created. So I am opening Postman tool to take this API. So I have opened postmen here. First of all, we need to start developing server. So PHP are the shin serve, pressing Enter, and if I copy the base URL, coincide Postman listing the URL. And as we know that we have configured all EPA dot inside EPA dot PHP. So we need to add EPI is a prefix. So to call register route, if I go heel EPA dot PHP. So to call this register which is calling the register method, we need to pass post requests die. So we need to select he'll post request. I go inside these headers, let's say Content-Type. Read to pass application JSON, accept its application JSON. Go inside this body, select a row. And inside Hill, we do pass all the parameters like what we have taken as name, email, password. For this rule, we have password under scope confirmation, and next phone number. So if I go here, first of all, we need to take some validation errors. So let's say that I will pass name here it is, which is containing null value. Next we have the email field, again, which is containing the null value. And here let's say password, which is containing null value. So if I click on this Send button and also read to add register hill, because this is the route name Send button. And here, as we can see that via getting error messages, that is the name field is required, email field is required, and password field is required. So let's pass on value. So I am passing the first student with this dummy e-mail value. Password is from phone to six. If I click on this Send button. As you can see that via getting Aquino error message, that is the password confirmation field men spur password field confirmation does not match. So for tat Vince to add one more property, that is password underscore conformation. And this adder we got because we have added confirmed as a rule inside this input field. Back to Postman. So password confirmation, we do pass exactly the same value what we have inside this password field. So one to six. And let's add one more input value, that is for the phone number. So phone number, this file's not required, but we'll pass this value as fell. Now click on Send button. As you can see that students registered successfully not be Fight back to browser. Click on Browse button. And as you can see that via getting our first student data, Whitney email has value of password. As you can see, it is totally has and here is the phone number. Let's create two Venmo user back to Postman. I will change and unmuting lead desktop these credentials one more time. As we know that inside this e-mail, we have added a rule called unique pseudo task, unique Validation, click on Send button. And as you can see that the email has already been taken. So I am creating the second student with this e-mail value. Password will be seen. Mobile number this time something different, value, pressing Send button. Students registered successfully. Back table, reload this page. And this time now we have two different rules. Now in the next video, guys who will create Logging API. So far this realization guys, thanks for watching and have a great day. 25. User Login API: Hello guys. Welcome to the course off larval, eat EPA telephase two real, this is our path maternity fall. Inside this video. Create student login API. If I packed editor. In the last video, we had created register API. By the help of this register method and its API, we had created few students inside this string steeple. Now at this time, by the help of email address and the password that will create a login API so that student can login successfully. And after login, who will generate a sanctum toucan? After generating sanctum token, we're able to use all of the routes inside this group metal V0. Because all these routes, as you can see here, these are protected and all they are needs are sanctum token, authenticated, sanctum token. So let's see all the steps. If I back too soon can go inside this login method. So inside this method, first of all, we will do some validation with the requested parameters, like we'll pass email address and the password to login any student. So we need some validation or input fields. Next, we need to check student that is to an axis or not. After that, to create our token. This is our sanctum token. After that, we will send our response, send a response. So let's see about this validation first. So we will use request incense and validate mattered. And inside this will pass an array. This is email and password. These are the two input fields, and we'll take inside this login API. So the rules are required. And we need a valid email format and actually the password only required. All we had done with the validation coincide this jacket student, Let's say that we have passed or e-mail address and a password. Now in the next stage for you to check that these credentials, what we have passed is correct or not. So first of all, in the first stage of this check a student, we will compare the email address, but we have passed is accessed in our database or not. So let's say that student equal to student model. And we will use a view mattered email equals 2 and heal. It's a request and email. And we will use first mattered. So when we will pass the email address. Via comparing the e-mail address with the database email field. If it exist, then it will return our student object. Otherwise, this object will be empty. So in the next step, what do you have to do? Let's, if it said it's a student ID eight months that this block says that if we have a valid student e-mail address, that it will return the student ID. So it is set otherwise. Here we'll have an else block is return response g sin. Passing an array. Let's see status equals to 0. And message. Let's say student not found. And also let's pass. 404 is two the school. Now, if I put these two comment lines, go inside this if block, basting a two. Now let's adapt email address part we have passed is available inside our database table. Now in the next stage, V to take the password. So to compare password because we will pass the baleen text value inside a wall request. So we will continue the plain text password with the highest value what we have inside our database. So what I will do, we will use the CEC method of hast class. In the last video, we have imported here as we can see. So go inside login method. Let's if hash inside it, we need to use Jack method. And inside this check method, look at the intellisense. The first is the value, it means plain text value. In the second we do boss has value. The first value is coming from request, and the second value is the comparing value coming from database. So here, the first value something request password. And next let's see Student and password. In this line. What we have done simply, we're comparing this plain text password hash value, what we have inside our database. So once this email will be verified, if this student exist in our database, so then we're taking its password. Now next, I will, again, could these two lines go inside this if block. Here we'll have Else block. Copy this response. Go Hill listing a tail. Now this time the masses should be something password didn't match. So it's a password didn't match. And finally, here inside this if block eight min stat, successfully, we have verified the email address and a password. So after successful verification V to create a sentence token. So how can we create simply it's a token equals 2 student means this is an instance of a student object is trend model, sorry. So here we'll use a method called create token. And one more thing before creating any token, if I back to database, go to real. And as we know that when we had installed the sanctum settings sanctum package, this is the migration file what generated right now inside this personal access tokens, there is no entry, but editor. Good token. Here we need to specify a token knee, let's say OT underscore token. And here we will use plain texts token. Now if we receive successfully we have generated or sanctum toucan. Now we need to next to send to the response. So let's return response. Jensen. Passing an array. Let's say that status equals 21. Vacillate student logged in successfully. And finally, we need to pass access token. It's the access token. And here inside this variable, via generating the token value. So let's summarize this code one more time. What we had done simply in the first few lines, we had done the validation of input fields. Next, we had done to check this e-mail address exist or not. What we have passed inside this request. If this email address Xist, then via taking its password. Otherwise, if E-mail address what we are provided does not exist, then we will get a mass of something is not found inside this if block. Now we are taking its password. The password is invalid. Then in that case, password didn't match. Otherwise, inside this if block, we are generating or access token and sending inside this response. So if I save all the changes back to post man, if I copy this route, open a new tab. So here, instead of reduced all, it's a login API. Back to editor, go inside EPA dot PHP, the request type we have called a post request type. We need to select post request type APA login, go to Headers, let say content type application json, accept. Let's application JSON, go to body rho and he'll read to pass e-mail address and a password. So let's email. If you don't pass any value. Also, we have handled our validation, so we're not passing any value. Click on Send button. As we can see, we have validation errors like the email field is required and the password field is required. Now in this case, here we had done the registration in the last video. So I will use the same credentials. I will copy the email address, pasting it to you and ask, you know, that this password, what I typed is incorrect. So if I click on the Send button, password didn't match. And once we type the invalid email address, which does not exist inside the whole university, will click on Send button. The message we have student not found. So let's pass the valid details. This is the militaries and the password is from fun to six. Click on Send button. As we can see, status equals 21, student logged in successfully. And he has, you can see that via getting our access token value back to the database table, postal access tokens click on Browse. And as we can see that we have generated or access token with the name of auth token. Here is the token value. Ability means it will average to do any operation. And here, by the help of student model, actually we have generated back to Postman. Now he'll look at the structure of the sentence token. It, it is very, very lightweight in comparison of JWT token as well as passport token. Then we will see those tokens in upcoming videos. Then we will compute that this is very lightweight. So due to V, lightweight tokens structure, it is highly recommended to use in single-page applications. Now in the next video, guys, we will walk for profile and logout API successfully. Inside this video, we had seen the login concept and also all about the access token concept. So for this video session, gas and for watching and have a great day. 26. User Profile API: Welcome glucose or lateral eat, EPA development Turiel. This is our partner 25. Inside this video, we'll create an API which display is print profile information. If I back to editor, in the last video, we had seen the concept of logging API. So if I go set up as GDP controllers, EPI, and here we have student controller inside this string controller. So far what we did all about this register API and login EPI. Now this time we will work for profile EPI. So inside this profile API, what we want if I back to post man in the last video, if I click on the Send button with the credentials like this. So as you can see that now we got our response protested as equals to one, mass is equal to student logged in successfully. And here we have access token. So when we create profile API, as we know that from EPA dot PHP file, if you go inside routes folder, EPA dot PHP. Now inside this file, as we can see that this profile API is inside this middleware group. So it means that file calling this API v2 pass access to convince sanctum token into header. So this token, what we have generated, we will pass the inside authorization key inside header to profile EPI and nothing else. In Profiles API, we will read this token and on the behalf of this token, we will drive the user information. Let's get started. If I back to editor, go inside is to add controller. And simply here, there is a very smallest code return response. Json status equals to run massive student profile information. Data equals 2 out. And here we have user. And return. If you save this controller file back to post pan, copy this out, open into a new tab. And keep in mind the request type for this profile APA is GET request die. He'll get request type. Now inside these headers, we will pass our token. So go heel. Let's do that. I will copy this token. Copy this back heel. Inside these headers. We will pass authorization key when I type alteration, as we can see, it will be automatically populated. Now inside this alteration key going set this value section and type other species and token value. Now if I press Send button, so here we have logging. So Institute of login. If I type profile, click on Santa button. And as you can see that we're getting all about our stream profile information. What will happen if we don't pass this token inside this header and chit-chat, click on Send button. And as you can see that we are getting some adder. If you go inside this row preview. Or to get the arrow in tier format, I will add few more hazardous and that is content type application json. Accept application JSON. Now walking, keep in mind via passing Content-Type and accept, but we are not passing alteration. If I click on Send button. And as you can see that we're getting message unauthenticated. Apes goes via passing this alteration token. But here we have misspelled the spelling of token. The token values not invalid. Click on Send button again via getting unauthenticated. So it means this is the token which is very important to read the information. So if I copy a keen go hill, if I remove this invalid token, putting a valid token, pressing Send button. And as you can see that by the help of this sanctum token via reading is student information. And also in the next video, we will walk over the lookout API. So by the help of this token, will look out this student from this system. So far this realization guys, thanks for watching and have a gritty. 27. User Logout API & Delete Token: Hello guys, valued glucose of larval eat epi darkness tutorial. This is our partner 26. Inside the suite you will see student lookout EPI. Inside last video, we had seen the concept of student profile EPI. Inside this profile method, we had used OT helper function. And from the OT helper function, by the help of token, we had retry the user information. Now this time we will walk over this lookout EPI, logos API means VM to delete the access token means the sentence token, what we have generated. So go inside this logout method in the last year, we had seen that this is the token we need to pass to get over the axis over this profile API. But inside logout EPA simply will delete this token so that this token will be invalid after logout. Back to editor. Go inside this logo to mattered. So simply what we will do by the help of odd helper function. We will retry all the user information. And from the user information tokens simply, we will delete that. Try to understand this line. This is what helper function. By the help of her helper function, really driving user information. It means by the help of sanctum token from the user information via deleting. It's all tokens. Here as you can see that. So this is the line. This line means that we are deleting the currently logged in user tokens. And simply, let's return response. Json. Making an array, Let's say status equals to fund. And the message student logged out successfully. Now if you save all the changes, go inside EPA dot PHP. So while calling logos API v2 pass authentication token inside header. Here stand out. So back to post pan. If I copy this URL open into a new tab. And for the logout APA, the request I've revolved something, GET request type. Back to Postman. So instead of profile, let's say logout and Vivo want to pass the authorization header. So what I will do, I will copy this butyl to convert. We have generated inside this last video, this is our valid token. So I have copied, go here, go inside these headers. And if I type alteration automatically, this key will be populated. So this is our token. Now next let's say content type application, json, accept, accept. This is not accept language, simply accept. Here we have the option and it will be application JSON. So now inside this lookout API and also inside last profile API, we have passed these three headers, authorization, Content-Type, and accept. So when we click on the Send button, this logout API will hit logo to mattered. And this load method on the behalf of token, what we have passed inside this header, it will retry the user information. From that information, it will delete that token and logged out the student from the system. So if I click on this Send button, as you can see, that student logged out successfully. If I back to this profile in the last video, does token had volt. Now as we can see that these token we have deleted inside this logout API. This token is now invalid. So if I click on this Send button, as you can see that unauthenticated alkene. To make used this user login into the system. Again, we need to pass the email address and the password because this token is invalid. Click on Send button, student logged in successfully. Now if I copy this token, go here inside this profile API, passing here, inside this header, pasting it here, click on Send button. And this is all about student profile information. Now, at the time of logout, simply the same token, we need to pass inside the header of this load API, click on Send button, student logged out successfully. It means we have deleted all the tokens of this user. Go to profile API, akin to click on Send button and on authenticated. It means user has been locked out. So step-by-step guides, we had seen the concept of registration, logging, profile, and logout EPI. From the next video, we will start for the other routes, like we need to create a list Prozac, single Prozac, and delete Prozac. All these routes. While calling all these API routes, we need to pass sanctum token inside header. So far this realization guys, thanks for watching and have a great day. 28. Create Project API: Hello guys. Welcome to the course of Lambda lead EPA data with Turiel. This is partner 27 and satisfied you will see the API. If I back to editor. In the last video, we had successfully completed all the API of registration, locking, profile, and logout. Also we had seen the sentence token. Now this time we will work on the facade controller. So go to App Filter as to TV controllers API. And here we have Prozac controller dot PHP nine. Satisfied you will fork over this, create posts that mattered. So as we know that from database table, inside this table, we need the parameter science student ID, name, description and deletion to create any Prozac student ID, we will get from the sentence token. Rest all the parameters like name and description and duration, who will receive from the body parameters. We will apply the validation or input fields like for the name, description and deletion if and only if these fields are mandatory. If I back to editor. So first of all, we will implement all about validation. Create data. And say This creates data. Also. We will get student ID, then create data, Silvio, and finally, centre response. Now first of all, let's apply validation. So as we know that we will pass sanctum token as well as body parameters. Now we will apply the validation over only the body parameters. Because rest the sanctum token automatically it will be validated by sanctum middleware. Now, here, let's request. We validate inside this array. Let's say we haven't theme. Next we have description and we have duration for this name field. Let's say that this will be required if I copy. And now name, description and duration, these three fields are required. Now next, we need to receive student ID. So how can we get student ID? We will read the student ID from sentence token. In the last video, if you open this student controller. Now here's the Profiles API to lead student data simply or the user data will use OT helper function and user mattered is odd and user will return the area of useful information. And this is accessing the user information on the behalf of access token, what we are passing. So go to Prozac controller, looks at that student and id equals two, odd, then user. And after that, we will pass ID again in five back to heal, go inside this file API. Let's login this user one more time. First of all, we need to start development server. So PHP addition, serve, dial up and silver started click Hill sanctum token generated. So if I copy, coincide this profile API, pass Hill, click on Send button. And as you can see that inside this data, we're getting useful information. And these are the information's basically return by Art use of luca. Look at here. So this all information. What we're seeing here, this is all returned by AAD user. Now we want the ID from this upset. So what we will do simply AAD user and ID. So by highlighting this, now if we are getting only the student ID, now next, first of all, go hill. Let's create an instance of Prozac model. So first of all, we need to import that. So use Prozac. Six-fold we have inputted are Prozac model known as we create the instance for z equals to new Prozac. And finally, let say the exact inside perceptible. We have student ID as a column name. Next we have knee. Two more fields we have. So if I copy base two more times, back to database table, student ID name. Next we have description. So copy and paste. And finally we have tuition, copy and paste. And all these values, we are getting it Hill. So for the student ID, we have the variable called student ID. Next we have for the name we will get from the request description. Let's request. And we will pass description as a key if I copy, pasting it here. And again, if I copy, and this time, this is for the duration. So successfully. Now here we have the tribe, the student ID, created an instance for product model, mass assignment of all the values. And finally, we will call the same method. Finally, we need to send the response. So let's return response JSON. Inside this, Let's status equals to one message. Let's have those sect has been created. Knife, you save, all these changes, go heal. And to call this create Prozac, the route we have good roads filter, EPA dot PHP, and inside this middleware group block here we have the route called create hyphen Prozac. And the request types would be post request, tie back to Postman. Copy this URL, open a new tab, pasting it here. And this time this is create, hyphen project selecting post request. I. Go inside this Hatteras. We need to pass content type equal to application JSON. Accept application JSON authorization as the key. And inside this V, to pass the token Sahel, we have generated a token of this user. So what I will do is simply copy this access token value. Go here. Cooperation, passing a bill for putting a space here. And then the key go inside his body because V to pass rest other three parameters like name, description and duration. So inside this body, select row, and inside this little name. Next we have description and we have duration. So inside name, Let's say Prozac when fun. Inside description, sample content of Prozac and duration, let's say for the six months. Now when I click on the Send button, as you can see that Prozac has been created back to double click hill. And as you can see that student ID equals to 2, name hill description here and deletion here. So successfully guys, this is the EPI. We have created four, create Prozac successfully. We had read the student ID from access token data access token is basically a sentence token. Now in the next video, we will vote for the other method like list Prozac API. So this was the video for the create Prozac. And inside this video, we had followed each step in very detail. Like we have validation. Here we're accessing the student ID from Tolkien, created an instance of Prozac model, assigned all the values saved inside database and finally, sending a response here. So far this video session guys, thanks for watching and have a great day. 29. List Project API: Okay. Is vacuum glucose of larval eat EPA, Dallas, Turiel, this is partner 28. Inside this week you will create lists Prozac API. If I back to editor. In the last video, we had folks and create it, create posX API. By the help of this method we had saved are present inside this database table. Now let's attack. We have thousands of entries inside this products table. Now what we want by the help of Lisp processing API, we want that when we pass the user ID, it wins sentence token inside this list Prozac. Then by the help of student ID, it will list all the Prozac associated with that student. So to list all the prospect of associated a student going satisfies mattered. First of all, we'd retry student ID. So let's say Student ID. We will get from AAD user and using ID here. Now next, let's have projects equal to Prozac model, putting via condition here. So via student ID, student under IT equals to student ID. And finally, we will use get mattered. And finally, after getting all the projects inside this variable, we will send to the response. So return response. Json. Making an array, it's a status equals 27 message. Let's say good checks. And finally data. And we will put our projects variable. So if you save all the changes back to post man to call this method, the route we will use in from this EPA dot PHP is EPSP something list hyphen Prozac and which is off GET request tie back to Postman. Copy this route. So before that, let's create few F2x inside this table. Right now we have a single entry. So by the help of this token, what we have past OF US ID to, let's say Prozac to duration equals to eight months. Click on Send button. Project has been created. Backed table, click here. And as we can see that student id2 Prozac to description and duration, let's generate 21 more token off other user. So inside this case, I will pass this email address. As you know, this is a registered user inside of a table. Again, hopping into a new tab. Go here inside his students, and here is the first user. Now what I will do, I will generate the access token for this user. Here it is. I will copy this access token, go here inside this headers. Look at the URL. This is off the heat Prozac. So we are creating Prozac by the help of this access token. It means student ID. When is going to create a preserved go to potty, let say protect 20, duration equals to three months. If physically consent button project has been created. Back to t will go and load this page. And as you can see that student ID equals to one. This is the name, description and duration. Back to Postman go hill. So if I will copy this route, open into a new tab, copy this URL institute, these two countries, the URL. And this time we should have the URL call list hyphen project. If I back to EPA dot PHP to verify the URL. So list hyphen Prozac, which is of GET request type. So it should be GET request I. Now NASW good headers. Here we need to pass Content-Type equal to application JSON. Now next pass Accept application Jason and he authorization. And inside this alteration, let's adapt film to pass this token value. So I will copy, go here inside this list hyphen Prilosec, putting bearer space and putting token here. Now when we click on this Send button, as you can see that student ID fun has created only a single project. Then we want to see for the student ID to how many projects is that it has created and the details. So first of all, we need to get the token of that. So if i back to profile, this is the token in the last video we have generated. So if I copy that go Hill list haven't Prozac authorization and I am passing the token, he'll automatically behind the scene that to convolute verified and the student ID ID will be fetched from the sanctum token. So if I click on the Send button, now as you can see that the total number of projects v hat equals to 2, and these are the details. And one more thing, if you don't pass this authorization key while the question is API, click on Send button. As you can see that unauthenticated. This is because we have wrapped all these APIs inside this sanctum within their group. So successfully guys, inside this video, we have completed list posX API by the help of student ID, what we are getting from sanctum token, we have retried all the projects from table. Now in the next video, we will see the concept of single Prozac API. So far this video session guys, thanks for watching and have a great day. 30. Single Project Detail API: Guys, vacuum to the cause of larval eat EPA developers to yell, this is our partner 29 inside this VT0 for we'll see single presented in API. If I back to editor. In the last video, we had completed create Prozac API as well as less Prozac API. Not this time, we want all about single Prozac API. We will pass product ID into the URL. If we go inside this EPA dot PHP server will pass to sucked IT while calling this route. So after getting this ID, we need to compare in our project stable. And if Project access to fetch all the detail and Son and to the response. So go here inside this method. First of all, we need to check on the behalf of this process. I did that. It accessed or not. So if let's say this is the model putting real method, let's say ID. Here's the idea what we are passing from the URL and we're taking by the help of accessed mattered. This piece of code is going to return a Boolean value like true or false. If projects exist on the behalf of this ID, it will go inside this block. Otherwise it will go inside this else blogs return, response, JSON, array, let's say status equals to 0 and message simply, let's say the exact Not Found go here inside this if block, it means Prozac Xist, we need to find that detail. So details equals to go Zach using Find method and here passing ID. So after getting details, this return response JSon, making an airy status equals to one message to Zach detail. And here inside this data key will pass the details what we are getting evolve. So successfully guys, this is the concept of single Prozac API on behalf of this ID. First, we are taking that it exists or not. If it does not exist, real turning this response otherwise via finding the detail and putting Hill inside this response. And one more thing we need to attach, that is passing student ID inside these conditions. Otherwise, what will happen in EPI means any student can access the detail of any Prozac. Because right now we're validating only for the project ID. But what we want, we want that inside this EPA call, we will pass sanctum token. From sanctum token, we will see student ID. From the URL. We will receive process ID. So on the behalf of student ID and project ID, we will compare and put all those conditions right here inside the sphere matter. As well as here. So what I will do, simply get rid of that. Inside this video. We will make an array. Let's say id equals 2. This is Id and unmuting drink to put the student ID. So student underscore ID equals 2. We'll get from heel. So user and ID. So if I copy this student ID, go hill, let's say student underscore ID and passing it here. Now next, the same condition, V2 pass here. So instead of using find, get rid of that and putting via mattered. So I will copy all these things from here. Putting it Hill. And I'm using good mattered. So if we, if we save all the changes back to boost man, if I take the URL first to call this matter that is single hyphen preserved. But to post man copy this URL, putting it Hill. And instead of list has been preserved. This time we have single hyphen preserved. And he'll free to pass Prozac ID. So before that, if I take the request type, so it should be GET request, I GET request. I'm going said headers, let's say content type, application, json, Accept application Jason. And one more parameter, we need something authorization. So we need to pass the key. So here's the profile information of students use id2. Now what I will do, I will copy this alteration key from this header, go hill, passing it till now next, we need to pass the Prusa IT here. So for now, if I pass the Prozac ID into the URL equals to 20. And as we know that 20 project ID does not exist inside database as well as for this specific token value. So if I click on the Send button, present not found. Now if you go inside this list Prozac, click on Send button. Again. If you go inside this profile, copy this bearer token, list hyphen Prozac, passing it heal. I will click on this alteration to enable this header. Click here. And now for the student ID T2, we have two projects, which has ID equals 21 and ID equals to 2. So when we pass, let's say product ID equals to three. As we know that this Prozac does not exist for student ID two. So when we click on the Send button, Prozac not found. But when we pass the second number ID, which is a valid Prozac, reheated by student ID T2. So click on Send button. And as you can see that we're getting detail of that project. If I back to database. Now inside this project's table, as we know that we have one more process that is id equals to three. So when we go inside this postmen bus here, Prozac ID equals to 3. Click on Send button. Prozac not found because this is the token actually generated for student ID to. But for this project, we have student ID equals to one. So if we want to get the Prozac information of this id equals to three, we need to pass the student ID one token. So how can we generate simple, we need to go inside this login API. Pastor details of user click on Send button, access to content related. So simply copy go hill. First of all, pass it here inside this header. Now next, if we pass Prozac ID3, and as we know that this project ID 3 is a successful valid Prozac for this student ID. So if we click on the Send button, as you can see, that this is the Prozac seriously has been created for student ID when. And one more thing, as we know that by the help of single-process API, we are getting only a single project today. Instead of using getMethod, I will use first method via, via using first method because as we can see that inside this array, we are getting a separate upset. But as you know that the project is going to be display as a single entity. So why we need upset here? So this time we have removed the getMethod from forced mattered. So go here, click on Send button. And as you can see that instead of array via getting upset features displaying a single project detail. So this is all about guys to fluctuate single-purpose at API. Successful, we had to retry the student ID via taking inside of our projects table that on the behalf of these two conditions, Prozac exist. If it exists, then we're fitting all the details and sending inside this response. So for this realization, gassing for watching, and have a great day. 31. Delete Project API: Okay guys, welcome to the course of lateral aide, API dapper Turiel. This is partner 30 and satisfied you, we will see presented API. So if i back to editor in the last video, step-by-step, we had completed all the APIs means, all the methods of this. Second too low. Only we have the last database, delete Prozac. So from this method, what we want when we pass the Prozac ID into the URL. First of all, we need to check that if data's student has been created this project or not. If the authenticated user has created that process, then we will delete from database table otherwise access denied. So here, first of all, inside this method, we do receive student ID from sanctum toucan. So let's say Student ID equals to art user. And here we'll use ID after getting students. Now next, here we have the value of student ID and here's the value of Prozac ID. So we need to compare as what, what, what we did in the last video to check that the project exit on the behalf of this ID as less on behalf of a student ID. So the same steps we need to do for this delete Prozac API coherent side. This block lists if V0 making an array, and let's say that id equals 2 id. And here student underscore ID equal to student ID and free to use accessed mattered. And finally, if present does not exist of data student or if an invalid project ID we have. So in that situation, we have the response as Prozac not found. Otherwise. If Prozac Xist offices tend and this ID, then we need to find that Prozac from database table and delete that. So here, Prozac equals to Prozac. Let's say we'll make an array id equals 2, ID, student ID, ID. And we will use first mattered. So here from these lanes, what we are doing simply on the behalf of this project ID means ID and student ID via finding present upset from TP after finding this offset w0 to delete that. So to delete, we will use delete mattered. And finally, sending a response to return. Response. Json, making an early status equals to 1. And message to set has been deleted successfully. Now if you save the change to call this method URL, we have, if you go inside this group, the URL we have called with the delete request type and delete hyphen Prozac while calling this method Read to pass the product ID into the URL. Back to Postman. If I copy this, go heel, open into a new tab. What I will do if we want to copy all the Haddad parameters, what we have passed here, simply go here and click on bulk at the, as you can see that we're getting all the keys. Simply copy, he'll go to this API route. Click on Hatteras. Click here on the bulk added, basting it hill. Again, click on key hyphen value at IIT. Now, as you can see that had those inputted successfully. So this time instead of single project, we have delete hyphen preserved. Now let's say that we want to delete this second number Prozac from this table. So Prozac ID equals to 2 and student ID equals to two. But instead of passing student ID directly, we will pass the sentence token soup back to Postman. Go here. First of all, we need to generate the sentence token of this user. So I think that we have already generated. So here it is. I will copy this alteration key from this header. Go here for the delete hyphen Prozac, passing util, changing from ghetto address type to delete request type, and passing here the URL and into this URL V to pass the project ID suffer. Now, if we pass Prozac ID equals to five, and as we know that this project does not exist. Click on Send button, Prozac not found. But when we pass two. So after getting these two value and the student ID from this sentence token, it will check hill. For the first piece of code. It returns true value. It will go inside this block, create a project upset. And finally, it will delete that back to Postman and click on Send button. Prozac has been deleted successfully. Now if I go back to our browser database, go into lewd. And as you can see that the project ID equals to 2 has been now successfully deleted from this table. Now again, the same request if we hit 21 more time. And this time as we know that this project deleted, so does not exist inside that they will click on Send button, not found. So successfully, guys, step-by-step. Now, we have completed our second phase of EPA development using sanctum authentication. I will drop the source code of this EPA fees to into the resource of this feat you. So far inside this course we have seen the basic concepts of EPI development, normally peer development, that, that was phase one. And here we had seen the concept using sanctum authentication, that is phase to the next video, we will discuss all about EPA dopant, that is phase 3 using JWT token authentication. And one more thing that all the source code of this EPA Fe2 and drop into the resource section of this video you can download the whole source code from. So for this realization, calcium for watching and have a great day. 32. Introduction about APIs & JWT: Hello guys, welcome to the course of lauryl aid, APA data points to real. This is our partner 31 from discretization guys willing to start over, told Face, API Management. And the last two videos, we had seen the EPA's dollar print without authentication, as well as we had discussed EPS data point using sanctum authentication. Now, beyond the third phase of API development, and inside this third phase, we will see API level using JWT authentication. If I back to slide. So for this third phase of API development, we will consider two different tables. The first table will have called users. Inside this user's table, if you will, is to the user information. And the column we will have called ID, name, email, phone number, and password. If we want more number fields, we can add here. In the next table, we will have a course's table inside stable release to user enrolled courses. It means the specific use of from this table can enroll a coups and that data through the store inside this causes t will. Inside this table. As you can see that we have the frills as ID, user ID, title, description, and total V2s. Also inside this third phase of API development, we'll see our relationship concept that is one-to-many, eight wins. A single user can enroll multiple courses. So we will do a single user entry multiple times inside the school says, only the difference is that each time each specific use of from this table will have multiple courses inside this table. Since I just EPA development third phase also you will see are additional concept that is one-to-many relation say. So let's see that photo, the API as well to create. So inside this third phase of API development, we will create a user API. By the help of user is through API, we will create useful and is 2 inside this user's table. In the next, we will create user login API. By the help of user login API, we will authenticate the user and create JWT token. In a second, we will discuss that what is the structure of JWT token? So for now, try to understand that inside this login API will authenticate the user details from our database. And after verifying, will create a JWT token. And the data generated JWT token is very useful to authenticate of valid user inside all these APIs. Inside this user profile, user logout and all of these APIs, we will pass JWT token inside header inside second phase of API data. When we had seen that how we have used sanctum token. We have generated sanctum token inside login API and passed inside authorization key at Hadar. Inside each request of other APIs, we have verified that the sentence token is overly will not. If it is not available, then we have displayed the message as unauthenticated. So we will create user S3 API, user login API by the help of JWT token, full validate, and get user profile API. Now next we'll create user logout API. Now here we have three different APIs. And these API is basically related to course's table. Inside this juicer, course enrollment simply will pass our JWT token and other details like title, description and total videos we will insert inside the school system will, in the next, we have total users courses. Inside this, EPA will implement our relationship concept, bypassing US IT, we need to count out how many courses that specific user has enrolled. And finally, we will see delete cools from USA. When will pass authenticated JWT token inside request. After verifying token will get user ID. And by the help of that user ID, we will delete a specific course from the school system will. So inside this, EPA will get a token as well as a course ID from the URL. So all these things we will discuss inside this top face of API development. Now let's see that what is the structure of JWT token? So if I go back to the official website, JWT CIO and he has, you can see that JSON Web Tokens are an open industry standard. Rrc 75 19 mattered for representing claims securely between two parties. Dwt Ohio allows you to decode, verify, and generate a JWT. The full form of JWTs something JSON web token. If I scroll down. And if you are interested to see, the introduction wins more about JWT. Simply click on this link. And here inside this document you'll find a complete introduction of JWT. Now inside this homepage. Here we have our JWT sample token value. First of all, did two token is compare the computed by using concatenation of three different token values. Here, as you can see that here we have the first value concatenated with the second value, and concatenated with this third value. So what basically this first value indicates? This first value indicates all about hetero information. And this header information contains algorithm and the type used. So this is the first part which contains the information of header. And inside header, we will find all these details. Tip. Suppose if we want to change the algorithm simply we can change here. Now next, this is the second part, which is payload. It means when we want to store our user information or any type of data to transmit from one party to another. We will store that value inside this second part. So second part is payload. Well, we will install all about the data. So inside EPA development, when we want to pass the use of value user ID via this token value. Let's do inside this blue data. And finally, the last section we will have called signature. So if we compare this token value to sanctum toucan so easily, we can see that the suntan token value is ve, very lightweight. So due to lightweight VEVO sentence token, we mainly use inside single-page applications. Not this time. This is JWT token. From the next video, guys will start our EPA down up and concept inside is told phase. So for this utilization, gassing, for watching, and have a great day. 33. Project Setup, JWT Installation & Configuration: Okay guys, Falcon glucose, so floridly, EPA data pair Turiel, this is our partner 32 inside the sweet you film to install lateral setup as well as JWT package installation. If I back to slide. So in the last video, we had discussed the scope of this third phase of API development. So here, here are the tables, and inside this list, here we have the APIs. Now this time, first of all, we need a lighting setup as well as DWT package installation. So simply, we need to use a composer command. By the help of that compose a command, we will create our level setup as well as to install JWT and configure inside lateral setup. We have few steps if you go to the slide. So first of all, we need to install DWT package. And the package installation we will do by using Composer. Now next, inside app.js file from config filter, we need to update providers array as less aliases array. Next, we need to configure our publics, our JWT config file after publishing this JWT configuration file. Next, we need to generate a JWT secret key. And finally, we need to update our ahd dot PHP file. So how can we proceed with application setup as well as this package installation? We have an article over this topic. If I back to ground, so this is blogging website or language or blog.com. Go inside articles, click on lauryl, eat. And if I search here, Let's dive JWT, press Enter. And hence you can see that we have an article over that topic. So simply, if I click on this article, scroll down. Now here, as you can see that we have the complete table of contents which indicates all about application setup as well as JWT package installation. So first of all, we need to install a lateral satyr. So for tat from this document, I will copy this composer command. So copy terminal. Currently if you're inside this folder, pasting it here, and let me call it as EPA phase 3. If I press Enter, we do it for a while because the settlement solution is in progress. And as we can see that setup has been successfully installed. If I back to folder structure, here's the folder. Let me open this folder into VS code a detail. And for the time being, let's create a database. If I back to browser, coincides PHP my admin, click on Databases. And let's say that EPA phase 3, this is the name I am creating for this third phase of EPA development. So I have copied, click on this Create button database created. And right now, this notable inside this database, back to VS code editor. And to configure or to connect with the database. Open up this file called a dot ENV. And from this dot ENV file, we will update all these DB connection variables. So he'll read to pass our database name. In my case, the username and password. Admin add 123. In my case, in your case, it may be different. So after configuration of this project setup as well as with the database connectivity, now we can install JWT package. So if i back to this blog article, scroll down. And here you can see that install and configure larval JWT odd. So here we have a composer command. Simply. I will copy this command batch terminal. And what I will do, first of all, we need to go inside our project setup, what we have downloaded. So CDI leads EPA phase 3. And inside the setup, we will install JWT OT package suppressing enter. And as you can see, that package now installed. So after installation of this package, back to article. Next week, we need to learn PHP addition migrate command. By the help of this command, actually willing to migrate all the pending migrations and create database t will simply copy this command that's terminal basting a tail. So before running this command, if I back to editor, go inside database migrations. So right now we have three, and these three are by default migration files. One for users table. Next one is food password resets. And finally we have failed jobs. So if I batch terminal, press Enter. And as you can see that all the migration now migrated successfully. If I back to database, reload this structure and we have the tables back to blog article. So the first step, what we had seen all about package installation, now we have done in the next step, we need to update this app.py file. So back to blog article. So inside this App.vue file from config folder, we should find two areas called providers. And aliyah says inside this providers a V01 to add this line. So simply, if I copy this line. Back to editor. Go inside Config folder. And inside this config folder, as you can see here, app.py PHP. So simply, you can search providers inside this file. All simply scroll down. And here's, you can see that we have our providers array. Now inside is NA simply. I will paste that line what I have copied. Now next, to copy these two lines and paste inside this aliases very simply copy back to editor, coincide this aliases and add the footer. I'm pasting those two lines. So successfully now we have updated this app.py file. If I go back to slide. So this is the step, but we have completed and the second one also completed. Now next, willing to publish our config file back to blog article. And here we have the command. So simply, I will copy this command. Bash terminal, pressing enter. And now DWT config file. Now publicist, we can find our JWT config file inside Config folder. If I back to editor, dilute this directory structure, go inside this config folder. And here's, you can see that we have JWT dot PHP file. Now next we to generate JWT secret key. So once we create JWT secret key, automatically, that secret key will be added inside this dot ENV file. Right now is we can see that inside this dot ENV file, we don't have any variable with the name court, JWT and discuss secret. But when we will create automatically, this file should contain a JWT secret key. Bat blog article. Scroll down to generate a secret key. We'd run this command so simply, I will copy, go heel, wasting TO press Enter. And as you can see that JWT secret now generated. And this is the key when we go inside this editor dot ENV file. And as you can see that automatically the key has been added now inside this dot in the file. If I back to slide. So step-by-step now we have completed from first to fourth position. And the final one, we have left update OT, taught PHP file, so forth that if I back to blog article, scroll down. And here's again see that configure OT God. So open up the file called auth dot PHP from config folder. From config folder we have ahd dot PHP. And inside this ahd dot PHP file, simply inside this defaults. We need to update god equals to API. By default, it is equals to web. So I should update EPI back to Article. And here inside this EPA re, simply when to change triumphal equals to JWT. By default, we will find inside these guards EPA driver equals 2 token. So inside the skied, I will change from toucan to JWT. So this is all about our basic settings of JWT package. Inside this lateral setup, few more settings left, which is associated with model. Because inside this model, as you can see that we have inputted this line as long as we have implemented JWT subject. So in upcoming videos, we will do all the lab settings with the model and other things. So successfully guys, in satisfied you have installed application setup as well as we have installed our JWT packet. So far, this realization gas and for watching and have a great day. 34. Migrations Setup: Hello guys. Vacuum glucose level eight, EPA database tutorial. This is apartment 33. Inside this video, we will see migration settings if I back to editor. So in the last video, we have migrated all the pending migrations. What we have by default of leeway inside is Migrations folder. So also we had this good The scope of tortfeasor API development. So we need to defend tables. That is first for user information and second, goals enjoyed by users. So by default, we have this user's table. Only. Need to add this phone number column inside of a user's table. Because whenever you have migrated, this is the users table. So inside this table, we don't have any column with the name call, phone underscore number. So we need to add that column inside this table. Back to editor coincide this migrations. Open up this migration of file that is created underscore users. And inside this, we need to add phone number column. So let's say that T-bill string, the column name we have called phonon, the SKU number. And let's say that the maximum length of this field equals to 20 character. So this is all about for the first table that is users. Now next, we need one more migration file for the courses table that will contain all these columns. Back terminal, we will use audition command to create a migration file. So PHP, artesian, make migration, reheat, lyse courses. Table. If I press Enter. Migration is creating. If I back to editor, go and download this directory structure. And as you can see that migration created successfully nine studies, courses table. We need to add our columns, what we want like user ID. So back to editor. It's a table in teaser. And the column name is something user underscore ID, which is unsigned. Now the next column we want something TBL. Next we have a string and the column name we have called the titles. So if I copy pasting it here, Let's say the title of this enjoyable course equals to 80 characters in land. Next we want the bill text, which is for the description. And let's say that it is nullable, means it will accept null values as well. And finally, we have total we'd use so which is in teaser. And the column name is something total underscore VT use. And we don't want this time is tens of values. So simply, I will remove the last method. What added inside these courses blog. And one more thing. This is the way to create user ID, which is in t-shirts and unsigned value. We have also the alternative way to create the same functionality is something table. And we have a method call unsigned in teaser. And inside these simply pass juice ID. So these two lines means this commented line. And this line will do the exactly the same thing what we're doing with this line. So now inside this course's table, the columns will have called ID, user ID, title, description, and total V2s. Now let's migrate that. So if i back to terminal, it's a PHP artesian migrate and unmuting. Also, we want to update this user's table because we have added phone number column here. So right now there is no column for number. So we need to update this table as well. So I will run PHP addition migrate, and I will pass refresh as a flag suppressing enter. This command firstly, rule back all the tables and then create all the T-Bills. If I back to database. First going satisfy users table structure. And as we can see that the phone number add it. If you go inside this course's table, go to structure. And here we have the user ID, unsigned value, title, description, and total we'd use. So this is all about the section for migration settings. In the next video, we will see the concept of model settings. So far this utilization gassing for watching and have a great day. 35. Settings of API Models: Hello guys. Volume to Gustaf loved leed, AP data pictorial. This is our partner 34 and satisfied you will see the concept of model settings. Back to editor. In the last video, we have generated our migration file. If I back to slide. So as we know that we will have two tables successfully. We have 10 rated these two tables in the last video, not this time, we need to model. The first model is for users table and a second for the courses table. So as we know that by default, when we install our level setup, this migration file already exists. So for this user's table, already we have a user dot PHP model file. Back to app folder Models. And here's the file. So this is also a by default generated file. Brand will install level Satyr next week to generate goes taught PHP for the courses table back terminal. Let's run that command. So PHP, optician, make model, and the model names should be singular. So it shouldn't be cores, which pointing towards courses, tuples. So press Enter. What are created successfully. If I back to editor, go and dilute. And here we have the second model phi. So I will specify some member variables here. So let's say first that is protected. I will tell this model that you need to point towards forces t will. By default, it automatically takes care of this course's table. But I'm adding for your information if, suppose in your case, if the table name is something different than you can specify data table name for this member variable. And one more thing that inside these courses, migration phi, we don't have any timestamps values. So we can form this model that we don't have any time stamp values. So public timestamps equals to false. Now here we have done all with the course's table and also wings to specify our friable property. So protected, fillable. All the day we had discussed about this property that is fillable, is going to take all the input values. We'll, we'll do insertion. So for this example, considers courses table. We want the values for this user ID, title, description, total vetoes. It means VM to assign. These input values to give mass assignment feature way to specify all these columns inside this fillable array. Otherwise, that value or that input field will not be allowed to insert into database. So we need to specify here. So user ID, title, description. And we have called total. If I toggle word wrap. Total underscore V2s. So these are the columns we have specified inside this fillable property. Now next, we need to open this juicer dot PHP. So when we had done the installation of JWT packet, also in that step, we had seen that we need to update this user model as well. So how can we update? Again back to this blog article? But we had open inside last videos. And here inside that we will see Setup user model. If I click on this link. And here we have user dot PHP. Now here we have a cushion. Cushion is that vibe be updating user.name THE model, vy naught V updating this course taught PHP. And it is because V updating user dot PHP because this model is going to give the feature of authentication. By the help of user model, we will do the feature of registration, login, profile, and logout. So that model, which is going to perform authentication features inside that model, we will configure all about JWT. So in our case, inside this third phase of API development, user dot PHP is going to perform all authentication tasks. So simply, what I will do, I will copy this line. Here. I have commented at this line. So simply copy goo here at this line here. Again, back to blog article. Simply going to copy this implements JWT subject and add here. This is our second step. Again, go Hill, stroll down V to copy these two methods called get jabbed the JWT identifier, get JWT custom claims. So I will copy back to the editor and paste inside this user class, save this file. So as you can see that it has gone. Now we have completed all about the model settings of this course, as well as USA dot PHP. So now we have the complete setup veal. We had done the migration settings, model settings, as well as JWT packet settings. Now from the next video, we will create routes controller and proceed with the EPA development tasks. So for this session, guessing for watching and have a gritty. 36. API Controller Settings: These glucose of larval eat EPA data tutorial. This is our partner 35. Inside this video, we will create API controllers. So if i back to slide. So in the last video, we had discussed that what are the EPA is we need inside this third phase of API development. So we had discussed that we need a user ESR API, user login, user profile, logout, choose a course enrollment, total user courses. And finally, delete goes from user. So for all these operations, we need two different controller. The first controller will be something user controller. We can say odd controller. And the second controller we need something, let's say horse controller, our enrollment control. So if i back to terminal to create controllers, before that, if I back to editor, go inside App as TTP controllers. So right now we don't have any controller only. We have the file controller dot PHP, which is by default. So we will create two different controller. The first, let's say user controller and the second course controller. So PHP, artesian mic, come to LA. And one more thing before creating controller. If you open this help manual. So inside this help man will, as we can see that vile creating controller also, we can specify the model from which this controller will be associated. So when we create user controller, as we know that inside user controller, we will use user model and vended create course controller. We will associate or accuse course model SUV will attach a while creating these controllers, solicit PHP, artesian, make gun too low. User controller and simply pass model equal to and the name of model. So if I press Enter controller created successfully, if I back to editor, go and reload. And here's you can see that via getting user controller. And here inside this container Phi Model successfully imported. And also one more thing that we don't want these user controller or course controller inside these controllers folder, what we want, all the PI controller should be pleased inside the EPA folder. So let's delete that. So unclicking this controller back terminal. Good job with this command. And what I will do here we have a user controller, so we want inside EPA controller means EPA folder. So simply, we need to add the folder name here, EPA and forward slash. After passing this value, pressing Enter Control created successfully back to editor. Go add a load this directory structure. And here you can see that we have an EPA folder user controller and the model imported successfully. Now next, we need to create goals controller. So if I batch terminal, again type the same command called PHP addition make controller. Folder name is something EPA forward slash and the controller name is something course controller. And for this case the model we want something goes here. So pressing Enter Control created successfully, back to editor, go and reload this actually structure. And here's, you can see that we're getting a course controller. So when we create this user controller with the model, course controller with the model, so by default, liable has generated the resource controller. So as we know that we don't want this resource controller. So what I will do, simply read remove all these methods. So let's remove all these methods. So simply, I will copy all these methods and remove from this user controller the same thing we need to do with this course controller. So what I will do, I will select all these methods and remove from this course controller. So instead of dat all methods, what we want, we want to use rest API, user login API, and profile look out inside user controller. Back to editor. Go here. Lets a public function register and thesis for user register API. Now next, we want public function login. This is for logging API, formulaic function profile for profile API. And finally, one more matter we want public function logout. So successfully guys, we have now created four different methods inside this user controller. So if we talk about the parameters in which we API, we need parameters to send inside all these methods. So for this rest API, we will hit using post request type, post request I. And inside this we need parameters because by the help of parameters, we will register a user. So inside this method, we need to pass to the request instance so that by the help of this instance, we can treat the party parameters. So he'll user, user register API. And this is by using post request type. Now if I will copy go Hill at a single line command, this is user login API. Also it will be post request type. And inside this login API, also we need the request instance because by the help of request instance, we will read the email address and the password by the help of those credentials, we will login the user. Now inside this profile API, we don't need any parameters. Instead, we need only JWT token. By the help of a JWT token, we will authorize, verify about its validation. And if it is valid, then we will fat the user details from payload. Because in the last video, also we had discussed all about the structure. So JWT contains header, payload and signature. Inside this payload privileges to all about Authenticated information. Back to editor. So this is akin, and this time it is using GET request type f. I will copy go, he'll be stinky tail. This is using GET request I, and this will be something useful, profile EPI and the user logout API. So all we have done with the older required matters of this user controller. Back to course controller. What are the methods we need inside these controllers? So public, public function. The first method we need something user course enrollment, it means the entry inside courses table. So inside courses table, we know we need the entries inside these columns like user ID, title, description, and total videos. So user ID we will fetch from JWT token, but rest parameters we need inside body. So also we need the request incense instantiates a course enrollments. So this is the method. And inside this method, we need to pass our request class and AKS create request instance, request and request. So if we add one lens single command, that is course enrollment API, and it is also using post request I. Now next, the next API we need, we need something total user courses. It means by the help of JWT token, we want to fetch all the courses that user has actually enrolled. So go here. Let's say that public, public function total courses. And inside this in the URL for will pass, actually not in the URL inside heads or we will pass JWT token that the parameter only we need. After getting JWT token, we will drive the user ID form payload. And by the help of this method, we will count the total courses enthralled by that specific user. So inside this API, if I add a single line comment that is total course, total costs enrollment API and it is using GET request type. Now next one, no matter we need something delete goes from USA. So inside this method, we need to pass JWT token as well as we need to pass our course ID and to URL bad editor. Let's say public function, delete, goes. And inside this mattered, we need a course ID. If we add a single line comment that is delete goals API. And this is using GET request tie. So here we have three different methods inside the scores controller. That is for the course enrollment, total courses, use of eyes and delete courses use of eyes. Now in the next video, guys will create API routes. And one more thing in that VT you fill will authenticate all about these APIs. Because user is true and user APA don't need actually any type of authentication. But if you are talking about user profile, user logout, user, course enrollment, total user delete goes then all these APIs to authenticate first via JWT token. So we will use APA middleware. So far this video session gas and for watching and have a great day. 37. Creating API Routes & Middleware: Hello guys. Welcome to the course of lauryl aid APA towel up into real. This is our partner 36 and satisfied you will create API routes. In the last video, we had created user controller as well as goals controller. Inside these controllers, we have all these methods, what we have created inside last video. Now this time we're going to create our API routes. So back to routes folder. Open up the file called api dot PHP. First of all, we need to import user controller as well as Corps controller. Inside is api dot PHP file. Soon as they use, user controller, use. And here V to create our EPA routes. As I had discussed that some of the APIs don't need any authentication, but inside some APIs we need authentication. So readout onto authentication V2 R1, register API as a last login API. These two APIs actually don't need any authentication. But if fear talking about profile, logout, all the matters of this course controller needs JWT token inside header. So all these methods we will make inside a group. So first of all, let's register our register and login API route. So route, post request type. Route is something register making an array. Inside this, let's say user controller. It's a class. And inside this class file, we have the method called Register. Simply. I'm pasting it here. Now next, we need to create one more route, and that is post request type. And the route is something login. We're using the same controller called user controller. And from user controller will use this logging mattered. So these are the two routes. Actually don't need any authentication. Simply, we will pass on body parameters and to have those like Content-Type and accept. Now let's create our group. So route hearing to create a group. Inside this group, VI to pass vigil veil. And inside this middle we'll V to bias our EPA, which will be next week to create callback function, its occlusal function. And inside these privileges, so our authenticated routes. So route we will use GET request type. And inside this, we have the Profiles API route, which is inside user controller. And inside the user controller, we have the method name as if you go heel and profiles simply. I will copy and paste here. So successfully now we haven't adjust to our profile route. If I will copy pasting it till now next we need to copy this lookout API routes. So copy this method name. You look out. And here we have out. So all we have done with all the matters of this user controller. Notice time viewing to use this course controller. So back to api dot PHP. So create goals, API routes, so route, go to course content. So here we have the force mattered, which is post request type and that is course enrollment. Good to EPA dot PHP post request type. Let's say the route name is something course in roll, insight is V2. Call, goals come to LA. It's a class. And inside this double-quotes, the matter we have gold course enrollment, Novocain. If I copy the same road. The next method we have called total courses, which is our GET request type. So simply gets addressed type. Let's a total hyphen courses. And from course can too low. This is the mat name. Now next, if I will copy, paste in detail. And the final method we have called delete goals, which is of GET request type. And also it will accept our IT value from URL. So copied method name back to api dot PHP. So here delete hyphen course and into URL V2. Pass cools IT. So here we have the course ID, GET request type, and the method name we have called delete cause. So successfully guys, now as you can see that we have pre-heated all the APIs. What we'll do inside this code phase of API development, inside these routes login in the illustration don't need a JWT token. Instead, they will generate. Now all these API routes what we had to then inside this group, they need a token inside authorization key inside hat, otherwise unauthenticated user response, we will get inside a screen. So far this realization guys, for watching and have a great day. 38. Create Register API: Okay guys, welcome to the course of law aid API developer tutorial. This is apartment 37 and satisfied you will create register API. If I back to editor. In the last video, we have configured api dot PHP. Notice time for will create register API back to user controller. Inside this user controller, here we have the first method that is register. So while registering edu, soil, water, the fields fever. So for tat, If you back to our database table, go to users. Click on its structure. So inside the users table to register any new user, we want name, email, phone number, and password. Rest. All the fields will have the default value. So we mainly pass name, email, phone number, and password. So if i back to editor, so here we'll use request instance. So let's request. We will use first, validate and vomiting. What are the steps we will do inside this register method? First of all, we will do validation. Create user data. Also will save inside that save. And the next, we will send a response. So let's get started all about for the validations. So request, we'll use validate mattered. Passing an array. And inside this array, the field we have called name, email, phone number, and here we have password. So for the name field, we want that the form validation rules, we have something like required. If I copy pasting a tail. So all these fulfills, we want that these fields should be mandatory, so all these required. Now next, the e-mail values should be a valid email format so easily. And also the e-mail address should be unique inside users table. So unique and he'll via passing the table name. So users. Now next four number, it is required password. And after required also we'll add one more validation rule that is confirmed. So when we add this confirmed rule inside his password, it means we need to pass one more parameter inside body and that is password and the school confirmation. Otherwise, we'll get an error, something password confirmation does not match. So here are the validation of what we have implemented. Now next, let's adapt via successfully passing the name value, email, phone number, and a password. So V to create a useful instance. So that After getting all these data, we need to save that user inside table. So inside this controller already we have used a model loaded. So first of all, let's create an instance. So use a new user. We have the name field, USO, we have next the email field. If I will copy this field two more times. Next we have for the phone number, and here we have for the password. So by using requests instance and we'll get the mean value inside this object. So if I will copy, go heel. This is for the e-mail value. For phone number. We'll pass the key, something like phone number. And for the password, we have the field name as password. And one more thing, when will create any useful and insert inside the users table, the passwords should be enhanced format. So in sanctum vile, doing in the second phase of API development, we had used that has baggage to make password has format, but this time we will use big crypt helper function. So be clipped inside this helper function via passing novel plain text password automatically this function will convert this bleed tax value into hast format. Now finally, after mass assignment of all these values, next we need to save into T will suffer, will use save mattered. And finally, return to center response. So let's return response. G isn't making an array. Status equals 27. And message, let's say user registered successfully. And also if we want to pass the Suitors, good. Also we can pass it here. Otherwise, the default value equals to 200. So after saving all these changes, Let's test this register. Epa's first of all, we need to start development server. So we are currently inside this EPA phase 3. It's a PHP artisan serve. Passing into our development server has been started. So I will copy this link back to Postman basting a tail. And for logistic API v0 to choose post request I. And the route is something register. And one more thing, all the routes, what we have configured inside this EPA dot PHP. So we need to add a prefix here, something API. So drought, we have God as http localhost 800 and put EPA forward slash register inside hetero V to pass content type application json. Next we have got accept application JSON, go to body select row. And inside this, we will pass the values as name. Email. We should have called for number. And finally, we have password. So if we pass the empty value to check our validation, data validation is working or not. Now if I click on this center button, as we can see that validation is working perfectly. Go heel. Now, if I pass the value As my name, go inside this email address. So let's pass this value. Inside this phone number. I am parsing a dummy value. And password is from fun to six. If I click on Send button. And as we know that we have used confirm validations rule. So we need to pass one more field that is password and the school conformation. So back to Postman goo here. So password underscore confirmation. And inside this V01 to pass the exact value what we have inside our password field. So all via passing, click on Send button, user is successfully. So if i back to table, click on Browse. And as you can see that we're getting the first value entry inside this user's table. Let's create the other user back to Postman. Let's change this name value. And this time I am using the CMI militarists to check the unique validation rule. Click on Send button. And as we can see that the email has already been taken solely since the e-mail value. Let's pass something different. Phone number. Password is from one to six. Click on Send button, user registered successfully. Bat table, click on Refresh. And now inside this table we have two different users. So successfully guys, inside this VT0, we have created register API. In the next video, we'll see the concept of logging API. So far this utilization gas and for watching and have a great day. 39. Create Login API: Hello guys. In fact, no glucose or low lead EPA data pictorial. This is our partner 38. Inside this video, we will create Logging API. If I back to editor. In the last video, we had created register APA as well as inside this database, we had created two different users. Now this time viewing to create login API. So while logging any user to the system, we need the email address and a password back to editor coincide login method. So while getting all the data, the first step we'll do all about our input validation. Now next, we need to verify the user survey for user. Next, we'll generate token, and finally we'll send response. So these are the steps we need to cover inside this login EPA mattered. So first of all, for this validation. And one more thing, we can merge these two steps like verify, user and token. So inside this validation, Let's request. We will use validate method. Inside this validate method, as we have discussed, that we need the email value and the password value, the e-mail values should be required. And also it's a valid invalid trees. So I will copy this require to coincide this pass food and pasting ETO. So all we have done with the validation. Now next, when to verify user and also after verifying the correct useful V01 to generate a JWT token to verify user with a valid email address and the password for we'll use our helper function. Go heel. Let's add purely US attempt to mattered. Inside this attempt method, we need to pass the credentials. So here we pass the e-mail value and e-mail value will get inside this request instance and email property. Now next, we need to pass password. Silver will get password inside this request instance with password property if I enabled toggle word wrap. So inside this odd helper function, we have attempt method. Inside this attempt method via passing user credentials like email address and the password ape. Suppose it is going to return a valid value. It means the user exist on the behalf of this e-mail and the password, then this will return JWT token. Otherwise it will return the false value. So what I will do simply amines to the return value inside is token variable. And one more thing, I will wrap this value inside this if block. If I cut this lane, making a block-based in the tail. So let's say that for the first time via passing this e-mail address is something different and password is something different. It means we are not passing valid user details. So in that situation, it will return the false value. So we will put hail the naught symbol, which converts of false value to true value. And in that situation, we'd return a response leads to response JSon. Creating an array. Let's state this equals to 0. And message, let's say that user simply in valid credentials. Now, this is the response we will get when we will pass invalid user details. And if, in case fear passing of valid email address and the password, it means the user accessed in our database. So in that situation, it will return a token value. So he'll return token value via touring inside is token variable. Simply coincide this response. Let's return response to JSON format. Creating an array. Let's say status equals to one message. You logged in successfully. And finally leads a token, or simply we can call it as access token. And the token value we have stood inside this token variable. All we have done here, we had done the validation. Here we are verifying useful and it's doing token inside this very Hippel and simply sending response here. Back to Postman. Copy this route open into a new tab. Post request type, go to Headers. Content type. It's not content land content type application, json go inside this and type Accept application JSON, body select a row. We need to pass the email address and the value. So email, for now let's pass empty value to check our Validation. Click on Send button. And as you can see that we're getting validation error. And I think that this registry VI because fear getting the error messages as name, email, phone number, password. So here we need to change the URL. So Institute of logistical, this is locking. Now if I press Send button and here we are getting their masters for this email address and the password. So in the first case, I will pass the invalid email address. This is correct email address what we have inside database, but the password is something different. Pressing Send button. And as you can see that we're getting the error message as invalid credentials. But when we passed a correct details, let's say password is from one to six. Email address is a great value. Click on Send button. And here's again see that status equals 21 locked in successfully. And here we have the JWT token value. If we copy this token values. So I will copy back to browser and open up the tool called JWT CIO. Go inside this debugger. And here we have the sample JWT token. So I will remove and paste our token. So here we can see that inside this token, the first part, what we had discussed is all about H2, which is containing the type and algorithm. Now next, This is the second part. Inside this we have the information as issuer issue or that explanation not before means all these details. And the final one, we have the CHO. So this is all about guys login API. So successfully now we have done the login section. In the next week you will work for this profile API. So far discretization guys, thanks for watching and have for greedy. 40. About Profile API: Hello and welcome to the course of level leed, AP data Turiel. This is our partner with 39 and satisfied you will see reheat profile API if I back to editor. So in the last video, we had discussed register APA and logging API. So one more thing inside is login API. That is, we have requested this valid user detail and successful, we have generated this access token. It means JWT token. So if I will copy this token, what we had done inside last week, you go inside this JWT IO, pasted inside this encoded section. And as we know, this token consists of three sections that he's had to be lewd and signature. Inside each section, we have different, different types of information. Like inside this header, we have type and algorithm type. Inside a speed loop, we have all these details. Now one more thing, that insight is P loop. We have EXP value. Exp indicates explanation value. This the timestamp value, which indicates that these token value is valid up to this time is time value. But in case if suppose we want to customize, if we want to actually add more time inside this expression value. So how can we customize this explanation value as well as this algorithm type? So as we know inside previous video, when we had done this deletion of JWT package inside the setup. Also, we have published our JWT config file. That file, how it is told inside this config folder and inside this JWT dot PHP file. So this is the file which is going to configure our JWT configuration 40 sat. Inside this file. If I scroll down here, you can see that this is secret and it is accessing all about our ENV JWT secret value. Go inside these keys array, scroll down. And here you can see that we have a section called JWT, Time to Live eight minutes. Here we can set the explanation value. The 16 indicates that we have in minutes. By default, any token will generate it is value for one novel. But when we want to customize, we want to add our own time simply. We can change here the TTL value, and then we want to change the algorithm type. So if I scroll down here, as you can see that we have a key called algo. So simply weekend pass our own algorithm type right here inside this ENV. Otherwise by default, it will pick HS 256. So how can we find the other algorithm types simply inside this G2, G2, THE file here we have the documentation link. The documentation links. Pointing towards a detail repo S3, simply copy, go and search. You will find all of the algorithm types. So by the help of this datable to conflict file, simply, we can configure and change the default behavior and the value of JWT. So now let's start all about Profiles API. So simply, by the help of profile APA, we want to access the user information which is currently locked in. And one more thing that this profile API or profile route is protected from middle, we'll call API. And one more thing, actually we forgot to add that is something odd colon API. So we need to add odd colon, otherwise it will not work as expected. So let's go inside is user controller inside this profiling method. And also we had this good all about Profiles API inside our sanctum section means inside EPA development phase 2, as we had discussed inside that video as well. That is, if we want to get the user data simply when to use odd helper function. And here we have our user mattered. So by the help of this odd helper function, use a method. We will return all about logged in user profile information. Now this time, we have all the user information inside is userData variable. Simply, what I will do, return, Let's response. So we'll use JSON method passing an array. Let's state this equals to V1. Message equal to, let's see, locked-in. It's not locked in. It is user profile data. And inside this we will take a data key data, and we will pass the variable as usual underscore data. Now if you save all the changes, go inside this post man, copy this URL, open into a new tab. This time profile API is of GET request I. So it is GET request type. Here inside these headers. Let's add that content type application json. Accept application JSON. Now as you can see that inside this profile EPA GET request is okay, but we're not passing any token. So let's see that. What is that? Actually we will get click on Send button. And as you can see that unauthenticated. And this is because we have added odd API as a middle V0. So this middle ways taking all about the token value, it means a valid token value. Back to Postman go Hill. Copy this token value. This is of 60 minutes explanation. Time. Go heel is authorization. Passing better? Making a space and pasting that token. Now if I click on Send button. And as we can see that user profile data. One more time. If I uncheck that key, click on Send button, unauthenticated. So to access the user profile data V, to pass a valid token value click consent button. And as you can see that we're getting the user information. So when we want a user ID, simply V to do the same concept, something like AAD user and v to use the ID property. So by putting this court use the ID, we can access the user ID value. So this concept we will use inside this course controller methods where we need user ID. So inside next video guys will discuss all about this logout API. So far this video session, guessing for watching and have a great day. 41. Logout API Function: Okay guys, vacuum glucose or flower lead API developer tutorial. This is our partner 40 and satisfied you will create lookout API. If I back to editor. In the last video inside this user controller, we had covered and completed all about this register method, login method, as well as profile mattered. Now this time we will work for this user logout EPI, which is a GET request type. And also for calling this route v to pass authenticated GW t value to use a controller. So simply, as we know that by the help of OT helper function, we can retry the authenticated user details. So inside this old helper function, odd, we have one more method that is Logout. So out and typing the name of the method that is logout. All we have done by putting these all to logout simply via deleting our token what we have generated. So simply return response. Making a JSON array status equals two FIN message. He looked out. Now if you save these changes back to boost man, copy this route, open into a new tab. Here we have a GET request. I go to Headers, bus content type application json. Accept application json. And if I change the URL, sending the lookout type Send button unauthenticated because we need to pass authorization token. So go hands at this profile, clicking inside this bulk update inside this headers because I want to copy its alteration key bulgogi. Simply I will copy this cauterization. Again, click on this key value at IIT. Go here inside this logout bulk added, pressing, Enter, pasting detail, click on this key value added. And hence you can see that we have an authorization key. Right now, the token we have passed is a valid token value. So if I click on the Send button, this is looking at EPA, which is going to delete this token R. It will expire that. So click on Send button, user logged out again back to profile EPA. And as we know that this token is not invalid because we have locked out. So click on Send button. And as you can see that unauthenticated, if v1 to drive the user information. Again, goo here inside this profile, once login APA, click on Send button to generate a user token value. So if I will copy, go here inside this profile EPA positive inside this mirror. Click on Send button. And as you can see that via getting a valid user detail, but the same token value. If we pass the same token value inside this alteration of this logout APA, click on Send button, user logged out. Again, click on Profile, an unauthenticated. So profile EPA, as well as the logout EPA are the simplest and easiest API. What we have developed inside this user can to law only we have used this odd helper function, choose a method or helper function and logout method. Now inside next video guys who will walk over this course come to low and see the concept of course enrollment relationship. We will see the concept of total calls courses. And finally, delete cuz mattered so far this utilization gas and for watching and have for clarity. 42. User Course Enrolment API: Hello guys. Welcome to the course of larval. Eat EPA dark material. This is our partner 41 and scientists read you will create course enrollments API. If I back to slide. So in the last video, step-by-step, we had done all about user registration, APA, use a login profile. And in the last video we had completed user logout API. Not this time. We will create, choose a course enrollment. If I back to database. Now inside this database, here we have a table called courses. Inside this table, if you will, is to the user ID information as well as cuz for this user has enrolled to insert a new row inside this course's table, we need user ID, title, description, and total vetoes. User ID will access via JWT token. So if I backed editor, go inside this course controller and inside the scores controller, here we have the first method that IS goes enrollment. We will read all the body parameters for this request instance. So inside this mattered block, what are the steps we'll cover? First of all, we will do all about our input validation next to nucleate, goals, observed, and finally, ready to send response. So let's do the validation first. So request, we'll use validate mattered. And inside this validate method, inside this array, we want the validation for this title, description and total videos. We don't need this user ID validation because automatically this will be taken care by Middleware. What I mean if I back to editor, coincide this API dot PHP. So here's the URL, what we'll hit to preheat course enrollment API. And this route is inside this route group, which is protected by our API. So automatically user IDs mandatory. Now next, we want to input fields like title, description and total vetoes. So if I copy this key, go Hill, it's a title. The next key we have called descriptions. So if I copy, pasting it here, and here we have the total V2s. So title, let's add that this will be required. Small r. If I copy this rule, pasting in front of the subscription and total vetoes. Now next, we need to create cause upset. So in the last video, this is the model, what we have inputted for this course come to LA. So by the help of this course, we'll create a course instance because this model is pointing towards this course's table. So back to editor. Go here. Let's of course, equals to new and cool CEO. So finally, we need four different values like user ID, title, description, and total videos. So let's say that goals choose the underscore ID and the user ID will get via AAD helper function. So if I back to user controller, go inside our profile API. So inside this profile EPA, as we had seen inside this profile APA, as well as logout API, that it will return the user upset. Inside this use upset, we have a key called ID. So to describe the USA ID, we have called out user and ID value. Now next, we want goals. Let's say title. If I copy this, paste it two more times. The second is for description, and the third is for total videos. So inside this title, Let's data request. So by using this request instance, we will have this title property. If I copy and go here, this is for the description and total vetoes. So copy, paste, copy and paste. And finally, we will use save mattered. So let's say cools. This is an instance of course model. And we will use save mattered. So finally, after doing all these things next week to send a response. So let's return response. It's not resolve its response to sin. And inside this, Jason will pass an array. Let's state this equals to 1. And he'll message, let's say cools, enrolled successfully. And also, if we want to specify our customers to DP code simply here because we can specify inside this second value. So if you save all the changes, first of all, we need to start development server. We need to open terminal. If we are using this VS code editor, here we have the menu called terminal. And if I click on New Terminal, automatically it will open a terminal panel from here. Also we can execute BHP optician serve command. Otherwise, back to folder structure. Here's the project setup. I will open this setup into terminal. Let's zoom in and simply type PHP artesian serve. Development server started. So what I will do back to Postman, copy this URL open into a new tab. And for our course enrollment API, we need post request. I go back to Postman. So when to choose post request, I'm going set is haters. And inside these headers, we need to pass three parameters like Content-Type, Accept, and authorization key. So if I go inside this profile APA go to Headers. So I will use the same headers. What we have passed here. Click on bulk at IIT. I will copy all these things. Back. He'll go inside these headers, click on bulk added, pasting it here we'll click on key value at it. And as you can see that successfully the headers now imported. So first of all, let's change this URL. So this time we have the URL call, goals, hyphen and roles. So copy. And instead of profile, I will replace with this value. Go to body select row. And here inside is going to pass title. Next we need to pass the description. And the final key we want something, total videos. So inside this title, Let's do that via giving our sample book as a core sample book and the description, Let's say that this is best schools to learn in WordPress and total video discourse continue, let's say 45 videos. Now, after passing all these values, now next we need to pass the authenticated user ID. So before passing this token value, if I click on this sand button, unauthenticated, it means that this token is either it will be expired or it is invalid. So first of all, V to login the user. So go here, this is register API, Logging API. So inside this login API, I will pass the username and email address and a password. Click on Send button. User is not logged in his the token. So I will copy this access token. Go here inside this course enrollment. Remove this old token value and paste in this new token value. Now, before clicking on the send button, if we want to check the validation, click on Send button. So as you can see that we have the AMT values for this title and total videos. So that's why we are getting that the title field is required and the total field values is required. If we pass the value, click on Send button. Course enroll successfully back to database, click on pros. And hence you can see that it equals to 1 title, description and total videos. If we want to enroll, one means more than one courses simply go here. Let's do that this time. Sample book 100 based course in level total, we'd use equals to, let's say 85. Click on Send button. Again, cause enroll, successfully. Go and reload this page. And as you can see that this is the second entry of user ID when if we want to cause enroll for user 2. So if I back to users table first, check the credentials for the user ID. Do we have this email address and the password? I think we have done like 12, six. Back to Postman going satisfies login API. First we want to generate a JWT token surpassing e-mail value and a password. Click on Send button. Token generated successfully. So Copy, go inside the schools enroll API, go to Headers. And the thing, we need to change this all to convey value means this is the token value for use ID1. And this time this is we use ID to go to body. So sample booklet say five, encoding knitr, total V equals to, let's say 50. Click on Send button. Course, enjoy successfully. If I back to table, click on browse and go inside this database courses table. So test-time, we should have the entry of use id2, title, description and total V2s. Now in the next video guys, we will see total user courses. So as you can see that inside this table for this user ID 2, we have two books. Now in the next video, we'll create an API by the help of user ID wins. Here we have the UserID 1 and use ID1 have two books. So data EPA, by the help of a one-to-many relationship, viewed, implement and create that API. So far this utilization gas and for watching and have a great day. 43. Total Courses API - One to Many Relationship: Hello guys and welcome to the course of lauryl aid, APA, DHAP, and Turiel. This is our partner 42. Inside this video, we will create total user causes API if I back to database. So in the last video, by the help of course enroll API, we had done some insertion inside this course's table. So as we can see that inside this table, UserID 1 has two books enrolled and use id2 has a single book enrolled. So we want to create an API by the help of data EPA, we will pass a JWT token and by the help of user ID, we need to calculate that how many books that user has enrolled if I pack to editor. So for tat, we have a method called total courses. So inside this, what we want, first of all, we need to find the user ID. And one more thing that in the last videos, I told you that inside this concept, we will use one-to-many relationship. Because as we can see from this table that a single user have multiple books, it means one-to-many relationship. So if i back to editor, first of all, V to create a relationship. So if we go inside this app folder, Models folder, and inside this model's folder we have user model. So inside this user model, we will create a method. That method actually creates a relationship with our course mortal. So if we go here, first of all, let's import cuz model Insights User dot PHP. So US Corps model. If I scroll down, go at the photo. And let's say that public function courses and inside this course's mattered. In fact, I will do simply return this. We haven't mattered. Cord has many. And inside this mattered, we need to pass the class name, means modal class name. So here, the other model we have something called cores and this is a class. All we have done. This is a user model which have one to many relationship. So we have created a method inside that model user dot PHP file, which is going to calculate total courses enrolled by a single specific use of. And one more thing, look at this method we have used has many. This is a method which is going to attach the user model, which has many relationship with course model, back to controller. And first of all, let's read about the user ID. So ID equals to OT helper function. And here we have the user method. And after that we will read the user ID value. And go here. Next, what we have to do simply, let's say user. This is model. We will use find method. And inside this find method, we need to pass the ID value. This ID value indicates all about user ID and we will use the courses as a property if we go inside this modal. Here we have the courses as a mattered. But when we use simply, people use it as a property. So by the help of this line, simply via finding all the course, by the help of this choose IT value. So still here inside our courses variable and simply literary turn. Response. G isn't making an entity. Status equals 21. Remove this package because automatically the map method. And here lets him message courses enrolled, total courses enrolled. And simply I will add one more key that is data. And this will contain the courses value. So inside this method, what we are doing via finding the user ID, passing inside this Find method. And after finding the user data via finding all the courses enrolled by that. All we have done, and these courses is a mattered. But we have created inside this user model, which has, has many relationship with the course model. Save all the changes, coincide this post man, copy this route, open into a new tab. And first of all, which requires time we are using for this EPA method, that is GET request type. And the route name is something total hyphen courses copy, go, he'll get request type and institute of course enroll. This time we should have total hyphen courses. So what I will do, I will copy again all the headers from hill. So simply copy, go inside this total core courses had those bulk at it and passing it here. And now, if we click on this center button, as you can see that the user ID two means this is the token OF US. Id2 has only a single course enrolled. Again, if you go here, let's generate the token value for our first user. So login, click on Send button, here is the token. So if I copy this token value, go inside this total hyphen courses, replaced with this token value. And finally click on the Send button. As you can see that this time we have to offset. It means the user ID when haven't drawn two different courses. So by the help of relationship, by the help of this relationship simply, we have calculated the total courses enrolled by a specific user in a very, very easy way. So this is the API guys fat we have preheated to count total courses enrolled by a specific use ID. Nine. The next video, we will see the concept of delete course API. So far this utilization gassing for watching and have a great day. 44. Delete Course API: Hello guys, welcome to the course of larval eat EPA development tutorial. This is our partner 43 and satisfied you will create delete user calls API. If I back to editor. And inside this course controller, we have the last method that is delete cuz method inside this method via passing course ID. So what is the plan for this method? Simply read to read user ID from toucan. By taking course ID value. First of all, we need to compare and find inside courses table that any value, any book enjoyed by this user ID and course ID, if it exist, then simply we need to delete that. Otherwise, no book found. So let's do that. First of all, let's read the user ID. So user ID we will read from this odd helper function, use a method, and we'll use ID property. Now next, let's see if Corps model, we will use veil mattered and inside the SVM method creating an array. First of all, it's id value. This is the course ID, but we are getting from the URL and the next user ID what we are getting from token value. So after comparing these two values, Let's say that if the book enrolled Xist, so coincide this block. Otherwise you will have ans block simply return response JSon status equals to 0 and the message something course not found. So this is all about for Else block. Now if you go inside the if block, It means we have enrolled with the help of this ID, User ID. First of all, we need to create a goals and standards. So course, we will use find method and simply will pass the course ID value. So this line is going to return a course model object and we're going to store in satisfiable and simply, we will use cores and delete mattered. Finally, let's return. Response. Isn't creating an array. It's a status equal to 1. And mass it, let's say Course Details successfully. So if you save all the changes, keep in mind this method will be hit by GET request. I need to pass course ID heel back to Postman. Copy this URL. If I open into a new tab, we need to pass the same Hadoop spins Content-Type, Accept and authorization. So I will copy, go Hill pasting inside this headers. Click here. How does imported successfully? So this is user ID one value which have two books enrolled. The book ID, something fun. And two. But let's say that inside this a URL. First of all, we need to change EPA route. It is something delete hyphen course pasting it here. So inside this URL, I'm passing a 100 value. And as we know that IT value a 100 does not exist. So if you click on the Send button, course not found. But when we pass, let's say the one value. And as we know that the course ID when Xist, which is enjoyed by US, ID one value, click on Send button, not here, click on Send button. Course deleted successfully. So again go here, click on Send button. So total courses enrolled by user ID 1 equals to 1 because the user means that of course I didn't successfully, we have deleted that. So this is the video guys all about oval, the last method of this third phase of API development using JWT authentication, that is, delete goes from US. And now I will make the zip of whole setup what we have tablet inside this phase three. And I will put into the description or into the resource section of this video. You can download the source code, but we had done. He'll simply, by going into the resource section. From next video, we will start the final, that is fourth stage of API development, that is APA data up into a level using Passport Authentication. So far this utilization guys, thanks for watching and have a great day. 45. Introduction about APIs & Tables: Hello guys. In fact, the glucose of larval eat EPA darpa tutorial. This is our partner 44 from this VT0 for really start all about food phase of EPA development. And this is by using Passport Authentication. Soon as this is our first video, super will see all about introduction of fourth phase of EPI dialogue main. So if i back to slide. So inside this fourth phase of development, we will use Passport Authentication, will take few tables like we have two tables for this development like authors and books. Inside these authors table privileges to all about authored details. So for auto stable, full create migration. And inside authors table, we will have the columns ID, name, email, phone number, and password. And next, we will have a second table that is pokes. And inside these books table, this to all book related information. And these books basically created by auditors. So if you go inside these books table, we have two columns called ID or tidy means the id column of this auto, title, description and book cost. So inside this table, privileges to all about book informations. So inside this fourth phase of EPI development, we will continue about the example of these quarters and book section. So vile implementing and developing EPA's also will see a concept of relationship that is 12 mini about this concept. Also we had discussed inside told phase of API development. So heal, a single Auto can have multiple books. So inside this example also will see the same concept that is one-to-many relation. Say, if I go to the next step. So what are the EPA's Vinge develop for this food phase of EPA development. So as we know via continuing with the example of authors and books. So we want few APIs, which is for the author, and few APIs for books action. So we want all about authorization while creating this EPA Vineet register authors. And we will use to autos information inside this or toasty. We'll now next after is to really use the login. And we'll create our two Logging API. So after creating logging API, you will see the concept of Passport Authentication. Passport is a composer package in the next video when we do the installation setup. So in that setup also will install a composer practice for passport authentication. So while creating login API, when we will use inside postmen, we will see the structure and what is the structure of Password Authentication, Bosporus token, we will discuss inside this Logging API. After that, we will have oughta profile APA. So simply after generating passport token, we will pass inside this profile APA. And by decoding that token for the tribe, the profile information. Next we should have called local API. So these all Fu EPA's relates with authors table. And next we have called rigid book APA lists, book API, single book detail, EPA, update API, delete API. So all these APIs relates with our books table. So we will start all about the development of this food phase of development from next video. So in the next video, all the way to do all about installation as well as passport package installation. So far this year, decision gas and coaching, and have a great day. 46. Project Setup, Passport Installation & Configuration: Hello guys. In fact, glucose of law, leed AP data to real. This is our partner, 45 and scientists feet. You will do the application setup as well as passport package installation. If I go back to slide. So inside last feet you, as we had discussed that we need two tables. Like first, we need autistic will, and second, we should have a books table. So by the help of this hot, stable, we will create few EPA's like register, login, profile and logout. So it means that alter table is going to provide authentication. So first of all, to implement and create all these EPA's way to create a SATA. So we do follow a few steps. So first of all, free to stall or Prozac. So if i back to blog, go inside these articles, click on lauryl eat. And if I click on the Search bar and type passport, press Enter. Now we can see we have an article that is rest API data up into level eat with passport simply. I will click on this article. Style tone. This article is totally from scratch, from installation up to application testing. So inside this video, we will see only the concept of presets setup as well as passport packages solution. So if I scroll down, so here inside this installation of lariat application, inside this, we should see a command that is composer. So simply, I will copy this command batch terminal. Currently we are inside this level photo. And let's rename it as something EPA faithful pressing Enter. And as you can see that installation I started. So for the time being, let's create a database. Sebastopol also coincides PHP my admin. Click on Databases. And let's EPA phase 4. So I will copy the name. Click on Create button, database created right nowadays, notable battery terminal. And as you can see that in solution now installed successfully. So V to go inside that folder, what we have created called CD EPI phase 4. And if I back to full the structure, so here we should see a folder that we have preheated. So simply, I will open this photo into VS code editor. So successfully as we can see that now we have imported hill. So what I will do next, the database we need to connect with this setup because the installation we have done database create, we have done now we need to connect that back to editor. Open up this file called dot ENV search for DB connection. This is MySQL localhost port. And in our case, the database name is something EPA feels full. And for my system, this is the gradient shoots of the database. In your system, it may be different. Back to slide. So the second step we have done, now next, window install passport package. Again back to blog article. Scroll down. So here we should see a section called install and configure larval passport. So here, as we had discussed, that does a composer brackets simply. I will copy this command, bash terminal, go inside this project, basically teal and press enter. We need to wait for a while because passport package is done installing. And as you can see that the process of installation now completed. Back to slide. We have done the third section. Now next, V2 migrate all the migrations. So back to blog article, scroll down. We will do in this command called PHP addition migrate, go Hill and to migrate all the migrations. So before migration, if I back to editor, coincide this database migrations. So here's, you can see that we have all these three like default migrations. If our elude go here, again, we have three migrations. So go inside terminal and simply dive BHP optician migrate. After running this command, it will go and run all the pending migrations. So after typing this command, as you can see that inside this directory we have only three migrations. But vile running, as you can see, we have or ought table, ought to contain a reference to continual clients table and personal access clients t will. So actually we'll, these migrations are coming. So these migrations are coming from passport package. Then we had done the passport package installation inside vendor folder. It has created the packet setup. And inside that package setup, these all migrations, full domains file resides deal. So when we run this command, it will go and execute all about the migrations of application as well as all the migrations of passport package. So if i back to database, go into load. And as you can see that currently we have our taxes tokens, OT codes, A-D client's personal access tokens and refresh tokens. So total five number of tables we are getting after installation of passport package. Back to slide. Now next, we need to update our auto model. So right now, as we know that we don't have any hotter model. So we will update our model in the next video. So here, here we have a cushion. Cushion is that via have, I have written called auto heal. So it's not only for the auto, this is the name of that model which is going to provide authentication. As we had discussed that from these two tables, like authors and books, the AutoCAD will is going to provide authentication. Wins for authors table, we have a register APA, logging EPA, profile, EPA and look out APA. So all the authentication process is going with the help of artiste will. And autos table basically leads with Author Model. So that's why we need to update automatical to accept passport token. Now next update or service provider dot PHP file. So to update this file, simply, if I back to editor, go inside this app. Here we have a folder called providers. And inside these providers photo, we should see a file called our service provider. Simply click on that, click on that file back to blog article. And if I scroll down, so before scrolling, hearing to run a command to actually generate encryption keys as well as secured access tokens. So I will copy this command back to terminal based in TO press Enter. Now it is going to generate client IDs and some access tokens. As you can see, heel back to article. Now next me to update the user model. So inside this article for this tutorial, here we have user model, but inside this case, instead of user model via operating all the authentication with these authors table. So that's why inside this section we have auto heal. Back to article. Now next we need to update or service provider, or service provider, you will find inside providers filter. So inside this file, what we have to do simply we need to add this line. So if I copy here we have a command called at this simply copy, go to editor or service provider. Adding heel. Now next, what we have to do, we need to add this line inside boot mattered. So I will copy. Go, he'll go inside would method. And inside this boot method, I am adding this. So after adding this line, it is wrong to provide passport routes. Back to slide. So all we have done with this authorise provider and finally v to update ahd dot PHP. So let's make a comment here that is for the next video. So auto dot PHP or two dot PHP we should find inside Config folder. And here we have ahd dot PHP. So what we have to update heel back to Article, scroll down. So orthodox PHP, we will find inside this config photo, search for guards. So simply go here, search for guards. And inside this Guards, what we have to do when to search for this EPA area. Inside this EPA, simply V to change driver here. So back to editor. So here we have driver. And this time we need to change here something called Passport. And one more setting when to do is that inside this ought to our PHP in satisfy EPA. Here we have for the users table. So as we know that v to use auto Sibyl soon the next video, when we create a migration and migrate January table inside this database. So in that situation, we'd change this provider value instead of users, we need to provide authors hill because authors table is going to provide authentication services. So for this video session guys, thanks for watching and have a gritty. 47. Create API Models & Migrations: Hello guys, and welcome to the course of lauryl leed AP data pictorial. This is our partner 46. Inside the suite, you will generate models and migrations. If I back to slide. So as we have discussed that we need two tables called authors and books. To create these two tables, we need to migration files as less two models. So if I batch terminal, we will use BHP addition command to create a model. And while creating model, also need to pass migration flag so that we can create migration and model help of a single command. What I mean simply by type VSP, artesian, press enter. It will open command palette. And inside this command palette, we should see inside this may command that is v have a command called make model. So by the help of make model view to create a new eloquent modal class. So if we want to open help men will die, will do VSP, addition, type help heal, and simply type the command name, that is MC model. If I press Enter. So when we run this command simply we need to pass the name of the class by the help of this name of the class, it seemed to create a new eloquent model class and heal. We have several options. So inside this options, as you can see, we have minus m or minus-minus migration. We're just going to create a new migration file for tomato. It means if we want to create author model by specifying minus m, also VM to create auto migration file. So let's use that effectively. Clear this terminal or console simply type PHP partition, lets him meek model. We want auto model and also we want or auto migration file. So simply I am parsing minus m as MTO model created successfully. And also we can see that it is creating autumn migration. If I back to editor, go and load, first of all to see the model file goin side AB models. And here's you can see that V0 have our TOM model to see migration, guns I database migrations. And inside this Migrations folder here, as you can see that also the migration file generated. Now next, we need to do the same command with the means over the next call, books table, batch terminal, PHP, optician make model. We want book model, weight migration for the books table. So press Enter module created successfully, as well as migration created successfully. If a back to editor diet here via getting all about for the books table that is post-migration. If you go inside this app models and also via getting book model file. So after creating water and migration, we need to vote on the migration files. So vata will do, first of all, go inside this Migrations folder, open up for the authors table. So inside this table, what are the columns we want? We want name, email, phone number, and password. Because by default, via getting ID column as well as time is time values. But we don't want timestamp values. So for that, we need to remove this line. And instead of dat vivo won't let saving one name. So it should be vacuum. That means we need to take a string value name here, let's say 120 characters and land. Next we want something e-mail address, which is a string values. So here we have email that's a 120 characters inland. Next we won't password. Also, it should be a string value password. Let's say it is of 120 cactus land, because inside this password field actually free will save has password via not going to save plain text value is that we have I unclip it has value. Now next, we'd take another string value, and that is for the phone number. Phone number. And this time it will take 30 cactus and land. So if I take all the columns, name, email, phone number, and password. So total five columns we have. If I back to migration, total five columns we have. So go inside these books table means book migration file. Also, we don't want this timestamp values. So here what we have to do at the first column after ID, we need auto ID. So if I copy the column name, go here. So table instance, we will use unsigned variable that is unsigned in TSO. And insight that this is our column name. And next mean to take like titles to copy the column name. Let's a table. It should be a string value. Passing it till it's a 120 characters and land. Next we have to take the next column as description. And the datatype for the description is something taxed value. And also it's an illiberal it, when it's zoomed to accept null value as well. And finally, we have book cost. So it will contain the in teaser value like V to enter the price of a book simply, let's say in teaser. And inside this, this is the column name. So these all the settings, what we had done with this author's table as well as with these books table. And also we don't want timestamp columns inside these authors as less books table. So we need to tell about the settings to the associated module files. Go inside App models, auto and Vinny to tell automobile is that v are not using any timestamp values. So timestamps equals to false. So I will copy the same settings, go inside this book model and pasting it here. So after doing all these things, batch terminal and type the command called PHP optician migrate, press Enter. And as you can see that autos devil created successfully as well as books, they will still go Hill. Dilute that structure. And inside this database, now we should see two more tables, status, authors and books. If you go inside this author's table structure, and as you can see, we have all the columns, what we have added. So inside last week you Venmo setting when to do with this autumn model. If I back to our passport article, go Heel Stone. So inside this article we have a section called update user model. So same settings when to do, but this time we have called our TOM model. So what we have to do simply be to import this line. So I will copy Gu Hill auto model and I and pasting it here via IVF using the disk quota model only because auto model is going to provide authentication services fit. Toasty, we'll soap pasted this first line and the second v2 use this has API tokens right here. So what I will do, let's say US or in front of has factories simply analyzed. This has EPA tokens. If I back to article and I think all we have done with this model file, we have added this first line as less added, this has API tokens. And finally, after adding these settings for this autumn model, we have one more settings left inside OT dot PHP. So coincide config folder To dot PHP. Since our last video, we have updated this Guards area means EPA passport and he'll providers equal to users. So inside the skis when to change auditors. So after changing or setting all these things, now we have done with the models and migrations. Now in the next video, we will create our API controllers. So far this video session guys, thanks for watching and have a great day. 48. Create API Controllers: Hello guys, welcome to the course off level eat EPA database tutorial. This is our partner 47. And satisfied you will create APA controllers. If I back to slide. So first of all, we need to understand that how many controllers, fee font, and what are those controllers? So as we know that via operating this fourth phase of API development with two T-bills, authors and pokes. Also, we have listed water, the EPA's we will create. Here. We have few EPA's for a juicer means authentication. And the next few EPA's, which is associated with books table. So simply we need to come to lose. First is all about auto controller. And second, that is book come to LA. So if I pack to editor, go here inside this app as TTP controllers. So right now we have our controller.js file. So what we want simply will create an EPA folder to store API controller files. It means V to create a folder inside this controllers folder with the name called EPI. And inside that EPA folder privileges to auto controller dot PHP file as well as book controller dot PHP file. So we will create those controllers via partition command. So let's have BHP partition mic controller. We need EPA controller, inside controllers folder that is EPA. And inside EPA folder, we want our first controller, that is auto controller. And also we want auto models should be associated with this auto controller file. If I copy this command, what I typed back to slide, open a new tab, basting a tail. So via using PHP addition may come to LA. This is the command. Here we are creating EP folder inside controllers. And this is our controller file name, that is auto controller dot PHP. And the model auto is associated with this auto controller file. Simply, if I press Enter controller created successfully, back to editor, go into lewd. And as we can see that we're getting or EPA photo inside this EPA folder here we have the file. And as you can see, auto model automatically imported. Now one more thing inside this auto controller. We're getting all the methods of resource controller, but we don't want all these methods because instead of index and create, we need Login, Register, profile and logout method. So what I will do next simply, I will remove all these default methods. Clean this controller. And now it is looks something like this. Simply save this file. Now next we need to create our book controller file batch terminal using same command, but we need to change some settings. This time the model is something book and the control of filename is something book contour taught PHP. So if I press Enter Kandula created back to editor, go into load. And hence you can see that via getting book controller file. And also for this control as well. We don't want all these methods because instead of using these methods, we need a reheat method for the book list methods, single method. So all these matters we want inside book on to LA. So we're going to use these default methods of resource controller. So simply select all these methods and remove. So let's discuss and create all these methods control of my controller. So inside this auto controller, we need, let's say register mattered, and this is using Postgres type. Now next we need a login method. It is also post request type. Next we need for filing mattered. This is GET request type. And finally we need logout method. And it is also using GET request I inside this register method B to pass some parameters. So we will use this request class. So let's create all these matters for us. Public function, let's say register. And inside this register method V to pass a request class. And also when to create our request instance. I will copy go here inside this login method comment genes, the method name, all the syntax will be seen. Again, if I copy go hill, inside this profile method, we don't need this request instance. And this is, let's say profile. If I will copy, go here and say it as logout. And one more thing in the next video, when we'll do all about EPA routes. So these two routes need not to be means grouped inside middle wheel, but the values in this profile and logout EPA's, these outs actually protected by middleware. Because before calling these methods V2 pass passport token. So that's why these methods and all the matters of book controller should be grouped inside a middleware. So this all matters. Now we have created inside auto controller. So same read to create few methods inside this book until last fall. So what are the methods we want? Something, let's say create mattered. Using post request type, Netflix. It's a list method. It is using GET request type, single book detail. So it is also using GET request type because we need to pass our book ID into URL. And like passport token inside header. So we don't need to pass any parameters inside the body. So a single book mattered, which is of GET request, I now mean to pass a deed method. It is using post request type. And finally we need delete method, and this is using GET request type. So let's create a one-by-one mattered. So public function, let's say Create book. And inside this, we need to pass on request class and create a request instance. I will copy the syntax go Hill based on YouTube. This is all about lists, a list and book. And inside this EPA, we don't need this request instance. I will copy go here inside this single book method, and this time says single book. And inside this method actually been to pass book ID. So let's say a book ID. And this book ID we will try from the URL now nagged for the update method. So I will copy the same syntax, go heel pasting it to, let's say update book. So inside this case, V01 to pass requests instance as well as book ID. Because by the help of book ID, this is DID what will pass inside the URL. So after getting book ID, we will update the book information and these informations will pass inside body. Now finally we have delete method. So if I copy this single book mattered based in ETO, cheese, the matter name. And it gives something delete book and this book ID we will pass into the UNL. After getting book ID, we will check that it exists inside table or not. If it acts is then simply we will delete from table. So these all matters not we have configured inside the book controller. And here we have four methods inside this article into law. So this is all about creating APA controllers. In the next video, we will make our EPA routes. So far this realization guys, thanks for watching and have a great day. 49. Create API Routes & Passport Route Grouping: Hello guys and welcome to the course of larval eat EPA tele pictorial. This is our partner 48 and satisfied you will create API routes. If I back to editor. In the last video, we had created these two controllers called auto controller, as well as book controller to register all EPA touts pool go inside EPA dot PHP. So to find EPA dot PHP, go inside routes folder. And here we have APA dot PHP nine satisfied. We need to route, we need to write all the routes. What we'll need inside this fourth phase of API development. So from this auto controller, as we had discussed inside last video, is that register method and login mattered. Don't need any authentication. Other EPA's like profile, logo, TPA, and rest. All the matters of this book controller need or authenticated token. So go inside EPA dot PHP footfall V to import our two created controllers. So let's say use our token to the next we have the hues. Let's say book controller. If you go here. Let's reroute by the help of post request type free to create our first API route that is full of cheese. So we need to create an array. And this register method V2 call from this author controller file. Go here. Let's say auto come to low. Inside this auto controller, it's a class. And inside this class we have a method called Register. Simply copy and paste it here. Now next, if I copy, paste it here, this is again post request type, but this is not for the login API. And this time we have the method called login. Now we need two more rounds for the profile and logout and all the other routes which is related with book. And to allow coincide api dot PHP rest all the routes need or authentication token. So what I will do v to protect all those routes like here we have two methods and here we have total five methods. So we need to protect via middle, we'll go inside EPA dot PHP V to create a group. So let's say group. And inside this group, what I will do simply passing and any, let's say middleware. And here v to pass odd API, need to create a callback function. And inside this callback function, we need to write all the routes which actually protected by middleware. So let's their health. And for the profile method we will use GET request type. The route will be profile. And it is from auto come to LA. It's a class. And inside this auto controller. We have the method call profiles as simply. I will copy and paste it here. Now next, V to create a route for login API. And login EPs also get regress type. So here, not logging actually look out. So V to go inside auto controller, copy these logout method and paste it here. So now successfully we have registered all EPA routes of this auto controller coincide EPA dot PHP. Now next v, to register all these matters and cricket API routes for this book come to LA and go here. Let's send it out to reuse the first post request type. And by the help of this post request type, we will create a book. Go here. And simply the route will be something. Create hyphen poke inside these, this time we'll have called Book controller. It's a class. And the mattered inside this case we have called create books or simply, I will copy and paste simply. Again, if I copy this line, paste it here. Now next we have list book, but this time it is using GET request type. So let's say get. We have the route name as list hyphen books. It is from pumpkin too low, and the method name is list book. Again, if I will copy, paste it here. Next we have single book. Again it is GET request type. But vile calling this method V2, pass book IT and to URL. Go here inside this EPA dot PHP. This time we have the route as single book. And this time it is again using GET request type. Go here calling single book. And one more thing, it is going to pass book IT and to URL. So simply pass here ID. Now next, we need to create roads for this update book and delete book. Go inside is EPA dot PHP and update book is using post request type. So if I copy this piece of code, go he'll, he'll post regress type, let's say update hyphen book and unmuting vile calling this method V to pass book IT also into URL. So vata will do simply pass Hill book ID. So let's say ID, create book. And this time it's not create book, actually update pool. So here we have updated the request type as well as passing book ID and to URL. And finally, the last method we have called for the delete book. So delete hyphen books. It's not books, it book. And this method we will call using GET request type. So GET request I mattered is something delete book and read to pass book IT and to a URL. So successfully guys, now that we have registered or API routes from this auto controller as well as from book and too low. Now from the next video, we will start working over this register, login, profile, logout, create book, and so on methods. So from the next video, we will vote on these methods. And in the very first video after that, we will invoke on this register mattered. So far this video session guys, thanks for watching and have a great day. 50. Create Register API: Hello guys, welcome to the course of larval eat EPA database tutorial. This is our partner 49 inside this VT0 for will work over a reducer API if I back to editor. So in the last video, we have registered all these API routes. Now this time we will vote on this register mattered. So inside this request instance, by the help of that, we can access all the body parameters, what will pass inside this register mattered? So what are the steps we have to follow? So simply, on the input data, first of all, we need to perform validation next week to create data and finally save data and sync response. So finally, step-by-step way to implement all these steps. So first of all, to perform validation, people use this request instance and Hughes validate mattered. If I make some zoom inside this editor. So here we have validate method. And inside this validate method, what I will do if a back to T-bill, go inside autos table, click on its structure. So we need name, email, password, and phone number. It means to register a new author. We need all these four different values. Back to editor. It's a name. Here we have email. Next week should have fast-forward. And finally we have phone number. So these all fields required from authors table, we'd need to create a new auto and save inside this table. Back to editor. Let's add few validation rules. So this is required if I will copy paste detail and I will add one more rule that is eBay for a valid email format. Next I will attach, let's say unique. And from autos table, if I take the table name its authors. So vile adding this unique authors, it means the e-mail address should be unique throughout this artiste will. Now next we have password. So simply it will be required only. And here, and I will add one more rule that is confirmed. It means after adding this rule, read to pass one more parameter inside this body that is password underscore confirmation. And here for this phone number, it should be required back to create data. So to register a new Auto V to use this auto Model. So first of all, we need to create an instance of that. So Arthur, new auto. And finally, let's assign values. So to assign values, if I go inside models first author. So inside this autumn model, first of all, we need to create or fillable property. Inside that label property, we need to pass all these values like all these column names, so that we can assign the values from auto instance. Go here. Let's define a protected variable that will be fillable. It should be an array. And inside that, I will pass all the column names of authors who selects a password. And here we have called phone and the second number. So save all the changes, go here. Now let's say name equals to request and name. This name is the column of authors table. And this is the mean value, what we are getting from party parameter. So let's auto. Next we have email equal to request. And let's email. If I will copy, paste it here two more times. This is for, let's say for the phone number. If I will copy pasty TO and the final field, we'll assign for the password. And as we know that V and we're going to save the simple plain text password for auditors. Instead of that, what we want or hast values would be saved inside this password field. So to convert a plain text value to hast value, we will use, first of all, let's distribute password privileged, use big clipped function. And inside that read to pass our plain text value. So successfully now we have assigned all these values from request to auto instance. So finally, we need to save. So it's auto. We will use save method. And finally, we need to send the response. So let's response JSon. And inside this creating array. And let's hit that status equals 21 and mass ij equals to, let's say, auto created successfully. So if you save all the changes, now we need to check the working of this register method. Go inside Postman. So first of all, we need to start development server. Currently we are inside this EPA phase who licit BHP artesian serve. After typing this command, it will open or start our development server. So as you can see, development server now is started. So if I copy this URL back to Postman pasted here, and if I go back to our EPA dot PHP file, so here we have the route name called register, and we have registered all these routes inside this file. So V to add APA prefix. So copy this route name, go here. First of all, type EPI register. It should be both request I go inside these headers past, let's say Content-Type. It should be application JSON and actually should have called Accept application JSON. Going set this body, select a row. And inside this body, as we know that we need to pass the name value, email value. Next viewpoint, password, password on the scope, gun formation. And finally we need call, phone number. So for now, if I pass the empty value to check all about input validation. So here I have assigned all the empty values to all these fields simply when I click the Send button. So hence, we can see that we're getting all about our validation messages. So let's pass some value. So here we are creating our first auto with this dummy e-mail address. Password is strong von to eat. Let's say password is from one to eat. Phone numbers, something dummy value. Now when I press the send button, as we can see that auto created successfully, if I back to T-bill, click here on the rows and the first AutoDock reheat it successfully inside this auto stable. Now again, with the same email address if I press Send button. Now as you can see that we have some validation masters, that is, the email has already been taking. So this is all about guys logistical API method. In the next, we will see the concept of logging API. Support this video session casting for watching and have a great day. 51. Basic Guard Settings & Create Login API: Hello and welcome to the course or flower lead APA talent tutorial. This is our partner 50 in satisfied, you will create Logging API. If I back to editor. In the last video, we had forked over this register method and created register API if I back to processor. So by the help of register APA, we had created a single author and saved inside this author's table. This time for the create login EPA inside login API, we will pass e-mail address and a password. After getting email address and the password will Valley deed of valid auto from this table. And also, we can see that inside this case means fourth phase of EPA development via using a different table to actually validate all logged in users. In most cases, in lateral application, we always use user's table to provide authentication features. But this time to register and login via using different people as we are using a different table called authors to validate or let's say for the login. So Vint do some configuration inside our application. So if I backed editor, first of all, we need to do inside two files. The first file is all about ahd dot PHP. So open up ahd dot PHP from config folder. Inside this auto dot PHP, we'd do a few settings if I scroll down. So here in the last video we had changed provider equals two authors. Now we revert back and change into users. Scroll down, go here inside is providers for these users array. As you can see that the model has been used called USA. By default. Larval always uses heat users table to provide authentication. But this time we're using a different table. So in that case, free to use our tomato because Author Model points towards authors table. So these two minor changes who read to do inside ahd dot PHP. The first change inside this EPA ARE we need, need to revert providers equals to users. Go here inside these providers array. And the second change we did something users array and change All About the Author Model. Now the next thing we need to do inside this author dot PHP model file. So first of all, we need to import few packages, let's say use authentic cable. And this authentic evil is coming from eliminate odd authenticate will again be to import vulnerable authentic cable, that is, and this time it will come from eliminate contracts ought. And as we can see that here, authentic people and Akin via getting authentic cable. So these two are same. So what I will do, I need to create an alias of the second authentic cable. So let's authentic able. And I will add as contract simply. Here we have the other package. And by creating an alias name, the same name has a different. Now, so what I will do simply, I will copy, go here inside this class definition. And let's implements authentic evil contract. Going inside this class, simply copy this authentic Gabriel and add inside this use. All we have done with this auto dot PHP mortal. Here we have a quotient. Quotient is that while we are doing these changes inside our OT taught PHP as well as Arthur dot PHP. And this is because actually via using a different table, like for the login and registration. So V to tell our larval application that via using a different t will so forth that we have changed All we have configured insight auto dot PHP as well as Arthur dot PHP. Because by default, larval always accept users table to provide authentication features. So after doing all these changes, go inside this autumn model. So this time we will use will login method. So inside this login method, first V to follow a few steps to create login EPA. And the first step that is all about input values validation. After that, we need to validate auto data. After successful validation auto data, we need to create a token. And finally, centuries prawns. So let's do some basic validation. Login data equals 2. We're using this request instance, validate mattered inside this validate method. Next, we need to pass the e-mail and the past fruit. These two fields will take inside the body. And the basic rule we will apply called required surpassing all these to heres. Now let's say via passing a valid email and password. So all these data now gets stored inside this login data variable. So non-access way to validate author data without autos table. So if really use or helper function. And we will use Atom to mattered. Once we have configured all about auth dot PHP automatically this OT helper function looks over our tomato. Otherwise, this author helper function always points towards users table. But if you go again inside this auto dot PHP, as we have changed the model equals to auto. Now at this time, this OT helper function always checks inside. Autocad, will close this file, go to attempt. Inside this attempt, what I will do simply, I will pass this login data inside this method. So let's say that v-naught passing a valid detail, it means we have either the wrong value of e-mail all it's a wrong value of password. So in that case, it will return the false value. So after getting false value, adding logical naught here, it will convert false value into true. So in that situation, I will return this response, let's say response JSon. And inside this, let's say status equals to false. And I will add a message that is something invalid credentials. And after passing the value means valley details. Now next going to generate a token, token. And this token is a passport authentication token. So here we'll use odd. Next we'll use user, again me to use one more method that is create toucan. And simply we need to pass the token name. And finally, we do return our response to return response. Json status equals to two mass ij equals to, let's say pot her. You logged in successfully. And let's pass this access token inside this response. So here we have the two can. Let summarize one more time. Actually what we did inside this video, first of all, actually via using a different table to provide authentication. So we had changed, we had done some changes inside our two dot PHP as well as inside this modal auto dot PHP. After that, go inside this auto controller. Simply here, we have implemented some basic validation. After that VIA checking our user data. It is invalid simply V8. And in this response, otherwise we are generating a toucan. Now let's test this EPA. So go to Postman. If I copy this URL open into a new tab. So instead of register, this is login, change to post request type boys had these headers. I will copy all the headers from this register go inside these headers, bulk at the basting a tail key value at the going set this body, select a row and hearing to pass the email address and password. Now, if I do not pass any value for all these fields, click on Send button. And as you can see that this is all about after adding our phone validations, like input value validations. Now let's pass some details here. And this time has we know that this email value is correct. As we can see by the help of data data, we have register a first author, but the password actually via passing is not correct. Click on Send button. And as you can see, a valid credentials. But when we change the value from, let's say one to eat, which is a valid password. As you can see here, click on Send button. Now as you can see that here we have our access token value. This is all about access token go heel. We have other token details. So in the next video, we will use this passport token to check inside our other EPA's that the user is currently logged in or not. And one more thing. In the second phase of API development via we had used the concept of sanctum authentication. Inside sanctum authentication, the token format, also in DWT authentication, the token format. And inside this passport authentication here we have the passport token. All the tokens are different inland. As we had seen in the concept of sanctum authentication, the token is really very lightweight. So due to that, we use inside single-page applications. So this is all about guys login API. In the next video, we will use this access token and unmuting that inside this access token via getting another access token key. So what I will do simply if I will copy go, he'll put here access token because this is going to return two properties. Like the first property we have access token, and the second property is all about token. So if we want to return this first object only, simply I have put your access token, save these changes. Again when we press Send button. And as we can see that status equals to true auto logged in successfully and inside this access token. Now this is all about past Pluto can, again, if I back to table clicking inside this database. And as you can see inside OT access tokens, if we click on that table, so heal the tokens what we have generated saved inside this database. So this is all about managing passport, passport tables behind the scene. So for this video session, guys, thank you for watching and have a great day. 52. Create Profile API: Hello, He's vacuum glucose level eight, EPA database tutorial. This is our pattern of 51. Inside this video, we will create profile EPI. If I back to editor. In the last videos, we had done all about register APA as well as login API. Now this time we will evoke over this Profiles API. So we will hit this method by using GET requests type and unmuting. If you go inside this EPA dot PHP, this route is under this protected middle V0. Eight wins that token. What we have generated inside last video, we need to pass this token value inside calling API. If I back to editor coincide is auto controller. Simply to get the user data, user underscore data. We will use odd helper functions. Odd. Who's all we have done? In the last video, we had discussed that this author helper function now pointing towards our trustee will. For tat, we had done some settings inside auto dot PHP as well as model file Arthur dot PHP. Otherwise by default is helper function always points towards users table. So after doing this, this line of code, simply turn response using GSM mat. Good. Adding an array lets his status equals to true. And message equals to, let's say user data or simply we can call it as the user profile data. And here d theta equals to simply leads the userData V to use GET request types. So if a pad to postmen copy this URL, open into a new tab, change it to profile. It is using GET requests, dive into add few headers. So if I want to copy all the headers of this login EPA going, set this header section. Click on bulk ID because we want to copy this content-type and accept bulk at IIT. Copy these two values. Go Hill headers, bulk at IIT, adding heal. And again click on Q value at eight. So successfully as you can see that we have imported to had us from this login API. Now as we know that this route is protected from middle wheel. So what, what will happen if I click without an ID token value inside this EPA? So simply unauthenticated suit to get over this EPA v to pass authorization key and the token value what we have generated. So if I copy the token value, copy that, go here. Let's add a key called authorization inside this via passing better space and pasting this token value. So if I click on this center button, and as we can see that user profile data now returned. So this is all about guy's profile API. When AN and take this value, it means we are not passing any token value. Click on Send button unauthenticated. If suppose via passing. And this token of values not correct because we have deleted few values from here, so it is invalid. Click on Send button again, are not indicated. So this is all about Profiles API. In the next video, we'll see the concept of lookout API. So for this review session, guys, thanks for watching and have a great day. 53. Create Logout API: Okay, He's vacuum to the curse of knowledge EPA database Turiel. This is a part of G2 inside his feet you will create local API. If I back to editor. In the last video, we had seen the concept of this profile EPA mattered. By the help of that, we had to try the user information from passport token. If I back to Postman, here is the EPI inside this API via passing our passport token inside this authorization key. So after successful validation of this passport token, we are driving the user information. So alkene, if I click on the Send button with this token is now working. Now inside the sweet you'll pull create a logout APA by the help of local TPA, we will logged out the user from the system. So if i back to editor. So before creating your logout method means logout EPA, we need to do few settings. Or we may say that we want to update few settings. Like previously, we had discussed that our logout method will be GET request I. So V to change here, it will be post request I. And also inside this logout method, we will pass requests class and we'll use request instance. Why we have updated this logout method we will discuss in few seconds. Go inside this APA dot PHP because this time we're going to use this logout method using post request type. So we need to update our logo trout as well. So it will be post request tie back to auto controller go Hill. So simply, I will use this request instance to read the user information. From tattoos information, we will drive the user token value. And finally, from that token value, we will expire that value. So water actually I am talking about simply request user mattered. And we will use token mattered simply by the help of this request instance. Fields driving user information and from a user information via accessing all about Passport token. So this is all about get token value. In the next state, V2 revoke this token value. So here, and we will store the token value inside this token variable. And simply it's a toucan. And we will use reform mattered. So simply, let's return response, response JSon. And if I put all about status equals to true. Message equals to, let's say Carter looked out successfully. So if you save the changes back to Postman, if I copy this URL, copy into a new tab, and this time this would be something Logo ready to change the request I from get to post request I go here. If I want to copy all the hetero, simply click on this bulk. Copy all these things. Go hand side is logout APA. Click on Heather's, click on this bulk at the and pasting it here. And again, click on Q value at IIT. So now as you can see that we have successfully imported all the habitus of this profile API. So right now, this token is working to retry the user information. But once we click on this logo tPA, this token value will be revoked. It means this will be expired. So when we click on this center button, as you can see that auto logged out successfully, the token now expired. If I back to profile EPA with the same token value, if I click on the Send button. And as we can see that unauthenticated, if we want to use this profile APA, again into regenerate the token value back to login API. Click on this Send button. Here is the new token value. So if I go copy this updated token value, go here inside this profile, EPA. Remove an existing token and paste in this new updated token value. Click on Send button. And it is working. Now if we want to use this logout APA, simply copy the token value n. Which user is currently logged in. Going side is logout EPA. Let's say beer speeds, putting these updated token value, click on Send button, auto logged out successfully. Again back to profile the APA. Click on this Send button, and it is unauthenticated. It means that token value now expired. So this is all about guys, how can we implement the logout mattered? We have very few simple steps. Simply, we have converted to post request type so that we can use this request instance. By the help of this request instance, we have read the user data to retrieve the token value. And finally, this token value now expired. It means we have reports that. Now from the next video guys, we will see the concept of this reheat book, EPA and so on. So far this year, decision cast and crew watching and have a great day. 54. Create Book API: Okay, He's vacuum to the course of learning, lead EPA database to real. This is our partner to three and satisfied you will create, create Poke API. If I back to editor. In the last video, we had completed all the EPA methods of these Oticon to low step-by-step. We had seen the concept of this register method, login method, profile method, as well as logout mattered. Not this time. If I practice the list of EPA's. So from this v2, from folk on our book can too low. So very first, we will create, create Poke API. By the help of tat. We will pass some book informations as a last auto ID. By the help of our tidy and book information, we will create a book and see inside our books table. So before creating any book, or if we want to insert any new book inside this T-bill, we want our tidy title, description and book cost. So if i back to editor, open-loop controller called Book controller. And inside this, we have create book mattered. So first of all, what are the steps actually we have to go for? The first step is all about our input value validation next V to create book data, next week to see if. And finally, centre response. So let's do all about the validations. We will use the request in stance, validate matter, creating an array inside that. So what we want, we want a title, description, and book cost. So let's say that description field is optional. So it means it will accept the null value. But the title and book cost, these two fields are mandatory. Rest the auto ID, if you will, it drive from the token value. If I back to editor title. Next we have the field called book cost. Again, if I take the column name, so it, it really book cost. And one more thing inside this book and to low viewing to use this book models. So please make sure that inside this book model, all these properties should be fillable. So if I go inside this model's folder, open up the module called Book dot PHP. Nine sites that I will add a protected property, something called fillable. And inside this array, Let's hit that vivo want authority means that this values would be filled. Next we want a title description. And the final column we have called book caused. All the columns we have assigned inside this fillable every eight minutes stat these columns should be mass assigned. If I back to Book controller, go hill. So let's say that v to add some rules or validation. So it will be required. And the next field is also required. So let's say via passing the values inside this title field and book cost. So after driving all this information, now net wind to create voc data. So first of all, we need to create an instance of book model. So what I will do, let's say book equals to new. This is how a book model. So book the columns we have called or tidy. If I again take the column names, so here we have our tidy. Next we have title. So if I copy this lane, paste three more