How To Make Multiple Authentication in Laravel 8 Jetstream | Multi Role Auth In Laravel 8 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome to a technology this is yamin and in this tutorial i am going to show you how we can create multiple authentication with laravel hd okay so if uh the user is logged in then it will take us to user dashboard and if the admin is logged in then it will take us to the admin dashboard okay so first of all we are going to create a laravel project uh let's create a laravel project uh in this youtube folder so let's open a cmd over here and press enter and for creating laravel project we just need to say laravel new let's our project will be name will be uh multi auth okay and press enter okay the laravel project is created so we can close it now and here you can see martial arable project that we created so let's go inside and let's just say over here cmd and it will open a common pump uh let's just say over here php our tsun sir and press enter now if we go to browser and say this uh it will show us our laravel project okay so now we are going to uh add just team login and registration using the steam in this laravel project okay so for this uh let's go to our project directory again and let's open another cmd and right now we'll say a composer require laravel slash jet stream uh it will install our stream in all our project and so press enter okay the testing is installed now we will uh install library so we'll say php rtson jet stream then irs install live wire okay and press enter it will install the live wire after installing live word we need to run this to command npm install and npm run dev i'm just going to copy it from here ctrl c ctrl v and press enter npm is installed now we will run uh npm render and press enter okay in npm download project using sublime text i'll click file then open folder our projectors are inside local leaks g then uh youtube and then multi-auth this is our project so select folder so you can see uh this is our project now first of all uh we will go inside database and then migration and then here you can see a lot of table uh we'll go to this user table okay so let's click user table and let's add a row over here uh which will be actually roll uh we'll say over here dollar string roll and it will have a default value default uh by default its value will be zero okay so if the value is zero it means uh it will be adding if the value is on then uh it is uh sorry if the value is zero it will be user and if the value is on then it will be admin okay so let's save it again and let's go to our uh over here dot enb here you can see that by default uh our database name is multi-earth which was our project name okay so we need to create this database so let's go inside uh my ps my admin and then let's click new then uh click database name database name uh here you can see that my our database name was martial okay so let's over here multi auth and click create you can see that the database is created which is this one now we will write the command uh php artisan migrate hp rtson migrate and press enter uh it will migrate all the table uh into this database multi-auth okay here you can see all the table is migrated now if we click over here uh you would be able to see all the database over here if you click user uh you can see over here name email role okay so now let's uh go to laravel and let's refresh over here and here you can see login and register option okay so let's just uh register 20 i'm into account uh let's say first one will be for user say user password one two three four five six seven eight on two three four five six seven eight and click register okay uh here you can see user is register okay let's log out and let's create another account let's say this time it will be for admin administrator gmail.com on two three four five six seven eight and on two three four five six seven eight and click register okay uh we also created another account for admin now if you go to our database and let's click uh sorry multi-auth and and then users uh here you can see that uh we created two user uh we uh and both of them role is by default zero so we are going to make uh make it on for admin so let's click edit and let's make it equal on and let's say go so we change the role for admin okay so it is on right now so let's go back to our code uh now we will go inside app then we will click providers and then you can see route service provider dot php okay just click it and over here you can see a public const home equal dashboard we will send it to which is over here or the directs okay so let's save it ctrl s okay now uh we will go to route and then web.php we will create a route over here for redirect we say route then get we see over here redirects re directs and then comma we need to say uh app then backslash http backslash controllers backslash uh let's see our controller name will be home controller okay and the class name will be let's say index so let's have them inside a quotation okay so let's save it now we don't have this home controller so let's create this home controller so let's go to uh cmd and we'll server here php rtsun make controller home controller okay and press enter oh sorry i did a mistake over here now let's press enter okay here you can see that uh home controller created successfully now if you go back to our code app then http uh then controller here you can see home controller now let's create the index function over here uh which we just mentioned over here we is over here a public function index and then uh inside the second bracket we will just uh three or four line of code uh first of all we will declare a variable is a dollar roll is equal to a auth then user role okay so actually this role is actually coming from uh the database uh over here from here okay and then after that after that uh we will say if our dollar roll equal equal uh equally fall on then uh return view to admin okay so return view let's say it will be admin dot dashboard okay and else uh if it's not if the role not equal on then uh it will return return view to regular dashboard i mean the user dashboard yes that's p-o-a-r-d port okay sorry i forgot to keep the quotation over here so ctrl s now we don't have this uh admin dashboard so we will create it we will go inside our resource then views over here we will create a folder a new folder let's say admin and the inside admin will say dash dashboard dot play dot php okay so let's save it control s and save and let's just see over here just a normal thing let's just say inside each one uh this is a admin dashboard for you okay so let's save it control s okay one more thing i forgot to add we need to add the use over here uh other uh okay so let's just copy it and let's paste over here we'll show our here illuminate slash uh support slash it will be packets package backslash auth okay here you can see uh we are using uh over here but where is is this earth coming from it's coming from over here if you don't add this line then it will uh throw you a error or exception okay so don't forget to add it so let's save it everywhere just to be sure okay so now let's go back to our code i mean uh browser let's refresh and let's click login now first try for add yeah user okay we'll try for user on two three four five six seven eight and click login okay it take us to user dashboard okay so now let's try to login for admin let's click login let's over here admin and password on two three four five six seven eight and click login okay it take us to the uh admin dashboard okay so now uh if you want to add like logon option for admin then uh just go to this user dashboard just copy this and paste it inside this admin dashboard i'll just paste it over here and let's just remove this part and let's see over here uh let's say inside center uh this is admin dashboard that i created because i am a genius okay so let's save it ctrl s and let's refresh uh here you can see uh this is the admin dashboard that i created because i am a genius okay so i hope i was able to help you to do a multi-role authentication in laravel it says team so i hope i also want to help you and if you like this video please uh subscribe my channel and if you face any problem then let me know in the comment section i will surely surely reply back and thanks again for watching
Info
Channel: Web Tech Knowledge
Views: 10,177
Rating: undefined out of 5
Keywords: laravel 8 multiple authentication, laravel 8 authentication, laravel 8 multi auth, laravel jetstream, laravel multiple authentication, laravel 8 authentication tutorial, laravel 8 jetstream, auth system in laravel 8, laravel authentication, multiauth in laravel 8, laravel 8 auth, auth in laravel 8, laravel multi role authentication, laravel multi auth, jetstream laravel 8, multiple role based authentication in laravel 8, laravel 8 admin and user login
Id: 85B7DsT75Y4
Channel Id: undefined
Length: 15min 38sec (938 seconds)
Published: Mon Apr 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.