Laravel Multi Auth with Breeze Part 4 | Multi Auth With Admin Guard

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friend welcome back in our previous video we successfully installed that laravel brief and also we did by default get everything right we now we are able to create some of the new user and also we are able to log in with this user and all that user data will be saved in our database that is by default on the table as a user table right here that will be safe i have already cleared on the user the name as user email address as a user at the gmail.com so now i want to do the same things for our admin okay now i want to create another authentication system for the admin for doing this we have to do first of all of our first work we have to create one of the migrations table okay so if you want to create this migrations table then there is another command uh here only you have to that is appropriate our file location right here i want to do on to name it as a php artisan and then make migration okay make migration and i want to create on the table name as the admins okay create underscore add means underscore table okay so that will be our table name now if you click as a enter it should be created on the migrations table file you can see that it's now successfully created and that in our migration that means you know database and there is a migration folder and here now it's created another database new table as admins which is totally fine so as i told you that will be just like our user so now if you go to that our user table and from to the user table i wanted to take some of the things from here okay i simply copy it i simply copy everything from to this position and now in our um in our another table that is i have created that is our admins right so into this admins area here after that i want to done to paste it so that will be one of the id then that will be another name that will be one of the email an email will be as unique and then email verified power and then the password right and also i want to take another better i take another field okay i take another field uh i just name it as a that will be the status okay status so for the status by default i want to do and to pass one of the value okay so i make it as a default and there is a default value here by default that will be inserted as a zero so if you want to do some other work later you can actually do this without this status field and this is status field i wanted one to make it as a tiny integer okay so teeny in teaser so i make it as a team integer great and a name will be as a string email will be as a string everything will be just like that same perfect so i simply added this and for the status by default when that will be created any admin user it should be saved as a zero value okay friend i simply created now if you click the save all and i also want to create another model for our admin if you want to create this model because here i will use that eloquent vrm so if you want to use that create that model then that will be a php rt sun and then make model and i want to create another model name as the admin model okay now click as a enter now you can see our model created successfully is very easy step by step just so we have to follow and now right now we don't need this okay right now there is a user we don't need this authenticated we don't need this and now if you go to that our model that means in our models now you can see there is our another model i have created as a admin so that will be just like our user so from to the user i want to do and to copy everything like okay from the use i copy everything okay copy everything which is totally fine and now in our admin i simply passed it okay i simply passed it great and then that will be the admin model that is our model which is totally fine here only we have to do in our user model that is the two things will be needed okay i simply copy both of these from here and now in our admin into this admin after here i paste it so i simply take it also don't take this part that means it has api tokens i copied and also after this i passed it okay now there is our authenticator user and then auth user and then authenticable and the notifiable has api which is totally fine and also that is our model so here that will be as an authenticable model okay make that sure that is the admin it should be extended our authenticatable okay i simply updated this and then has api is in here that is our hash factory and then notifiable great i also simply loaded everything in here and now that is our protected field level okay protected fillable every field is the same because here i name it as a name email and the password and only they have another one as a status okay i want to do and to add the things in our admins after that i to take another field this field will be also as a fillable and now we have to create one of the guard okay here if you want to create that guard wait around first of all i want to make it as a protected okay protect and protect it will be as a guard as uard guard so that is our protected guard and protected guard will be for our admin so here now we have to do we have to create this um guard okay here simply we have to create this guard and then i protected all that field and rest of this will be just like that same okay here we don't need to change anything everything is look like perfect and now if you click the save all and now i want to go and to migrate out this database table okay that is our database and in this stability i have created some of the field and if you know migrate that will be as a php rt sun and migrate now click on the enter now you can see our migration is now successfully done that means if you now go to our database table and this now there should be another one yes you can see now that is another table as a ad means and for the admins i name it as a name email email verify ad and password and then status okay now we have to do we have to create that guard okay here i name this right now we don't need this and also you don't need these there's the add means i protected me you make it as a guard will be as a admin right so if you want to create this guard if you go and in auth that means here i have already discussed about that things with your friend like just simply understand there is auth guard as a way so waveguard is for default when you install that laravel breeze that is one of the default guard actually laura will use as a web now i want to turn to create another one for the admin so if you want to create this guard you have to do you have to go to that config folder so there is another folder as a config and into this config folder you have to go to that auth okay and into this auth you can see there is guard is by default they're using as a whip now i'm going to do i want to add another one okay that is our guards and with this guards area here right now better copy it and then i want to do and to paste it and i want to do and to create another guard name that will be as admin okay that will be as admin and there is a driver will be as a session and provider will be our database field name or database field name as a ad means right so that will be the admin so now i name it as a admins great and now we have to create another provider that means that is the provider okay better i want to do and to copy it i simply copied and after this i pasted it so that will be as a our name or name i named it as a admins okay so i make it that provider name will be as admins driver will be as a eloquent and model will be as app models i have also created another model as a admin right that will be as a admin model so i simply updated this admin model great and rest of this will be just like that same here we don't need to change anything everything will be just like same okay here i simply created another provider for that means and that is our guard there is a guard name as a admin okay friend i simply save it now we have to do we have to create one of the middler and with this middleware now and to protect all that our url and to protect all the tower things without this guard that will be for the user default user will be use that webguard and for the admin i want to use that admin guard so how can do that work better to continue this process in our next video i will show you that things with the live example so thanks for watching i'll see you in the next video
Info
Channel: Kazi Ariyan
Views: 70
Rating: undefined out of 5
Keywords: laravel Multi Auth with Breeze, Multi Auth with Breeze, Breeze Authentication, laravel, laravel Multi Authentication, laravel 8, laravel 8 features, laravel 8 http session, laravel 8 installation, laravel 8 new features, laravel 8 tutorial in english, laravel for beginners, laravel a-z, laravel jetstream, laravel model factory, laravel new features, Multiple Authentication
Id: hIoM8ZYGtWE
Channel Id: undefined
Length: 8min 32sec (512 seconds)
Published: Mon Nov 29 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.