How to make Login System in Laravel

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends in this video tutorial we are going to make simple login application in laravel framework here we have create a simple laravel authentication by using laravel migrations seeding routes controllers and view we will develop this system step by step by using different laravel features there are many viewer has requesters to make video tutorial on laravel login system so we have make this video tutorial in previous tutorial on laravel we have already download an install a novel application and in that we've seen how to upload file in laravel so we have used that laravel application folder under this application first we want to make database connection so we have opened our 10 file in this file here we have right localhost in database we have right testing in username we have right root and password set to blank after this we have go to config folder database dot PHP file and in that file also we have defined database credential you this way we have make database connection after this we want to make user table in testing database by using laravel migration so when we have download laravel application then by default use a table migration file has been downloaded which can be found under database migration folder so we have opened this file and under this file we can see different users table field like it name email password and so on now we want to migrate this use a table to testing database so we have go to compose a command prompt and here we have write this command this command will migrate users table to testing database and users table has been created under testing database which we can see here and testing database now we want to fill one data into users table so we have used seeding technique of laravel and seeding file we can find under database seeds folder so in this folder we want to create user table seed a class so we have go to command prompt and write this command this command will make use a table see the class under database slash seeds folder which can see here so we have opened this file and under this we can see run function on this page we have here at user slash user model after this under run function we have right user class with create methods and under this method we have right array in Rey first key we have right name with value John Smith in second key mail with value John Smith at the Reggie mail.com you in third key password with value hash class would make method and under this we have write simple password this class will convert simple string to hash string now we have go to database seed a class and here also we can see run function so under this we have write eloquent class with OnGuard method after this we have write dollar this with call method and under this we have write users table seed a class name this method will call users table seed a class up method now we want to export this data into users tables so we have go to command prompt and write this command this command will sport this data to users table and insert into users table so this way we can use seed a class for export data into database now we want to create one controller so we have go to command prompt and write this command this command will make controller with named main controller in controllers folder now we have go-to controllers folder and under this we have open main controller file and under this we have make one index method so when we have called this controller directly then this method will called and under this method we have right returns statement with view methods and under this we have right login so when main controller has been called we want to load login form for login so this view method will load login view file now we have go to view folder and under this we have already make login dot blade dot php' view file and under this file we have already loaded query and bootstrap library under this page first we want to make login form so here we have write form tag with method is equal to post under this form first we have right open and close to curly bracket and between them we have called CSR ref field method for handle multiple exception now we have right input type is equal to email with attribute name is equal to email under this user can enter their email address after this we have rightt input type is equal to password with attribute name is equal to password under this tag user can enter password details lastly inform we have right input type is equal to submit with attribute name is equal to login and value is equal to login by clicking on this button use that can submit form data to server now we want to set root for index method of main controller so we have go to webpage P file under this we have right root class with get method with two argument in first argument we have right slash main and in second argument we have right main controller at index method so when in browser we have right base URL slash main then it will called main controller index method now we have check output in browser friend here first we have write base URL and after this we have write main then it has been display login form so this way we can display login form now we have go to main controller and here first we have right used statement with validator class for form field validation again we have right right use statement who thought classes for check user details authentication now we have create one new method check login with request arguments this method will received login form request under this method first we have right dollar this with validated method with two argument in first argument we have right dollar request variable and in second argument we have defined formfield in a format for validation rules so in Narae first key we have right email with value like required and email here this email field is required and it must be an email same way and second key we have write password with value like required alphanumeric and minimum length 3 here password field is required and it must be an alphanumeric and password length must be minimum 3 if this validation rules is not passed then page will be redirect to login form with validation error but suppose above all validation successfully passed then it will execute of the code part so first we have display validation error on view file so we have go to login dot blade dot PHP page on this page we have right at the rate if statement and under condition we have right count function with dollar errors variable value greater than zero this condition will check if this count function return value greater than zero then it will execute if block of code under this block we have right at the rate for each loop and under condition we have right dollar errors with all method as dollar error variable you by using this for each loop we can fetch errors value one by one and under this loop we have right dollar error variable this way we can fetch datian error and display on web page by using blade templating engine and laravel now we have go to main controller and now we have right dollar user data variable is equal to array with first key male value get from dollar request with get method with email you same way in second key we have right password with value get from dollar request get method with password text box field name this way we have store login form data into this dollar user data variable after this we have right if statement and under condition we have write-off class with attempt method and under this we have right dollar user data variable by using this attempt method can attempt to do the log in with user data store in dali user data variable if validation successfully then it will execute if block otherwise it will execute else block if users enter proper login data then it will execute if block of code and under this block we have right returns statement with redirect method under this method we have right main controller slash success login method so validate user will be redirect to success login method but suppose rent wrong details then it will execute else block and under this block we have right returned statement with back method and with method with two argument in first argument we have right error and in second argument we have right this error message by using back method page will be redirect response to the previous location with error message store in our variable which we can fetch by using session get method so for display this error message we have go to login blade dot PHP page and here we have right at the rate if statement under condition we have right dollar message variable is equal to session class with get method and under this we have write error if this condition true then it will execute if block and under this we have right dollar message variable so this way we can display wrong login details error message on web page now we have go to main controller and here we have create new method success login under this method we have right returned statement with view methods and under this we have right success login which is view filename which we have created under view folder after successfully login venues there will redirect to success login method and it will load success login dot blade dot PHP view file now we have go to success login dot blade dot PHP view file and on this file here we have right at the rate if statement and under condition we have right is set function with auth class with user method with email this condition will check this method has returned login user email address or not this method will return login email address if user has login into system and it will return true so only validate user can view this page and it will execute if block of code and under this block we have write welcome message with auth class with user method with email you here we have display valid at use a ream a lid on webpage below this we want to display a logout link so here we have right anchor tag width ref is equal to double curly braket and between this we have right URL methods and under this we have right slash main slash logout here logout paid link has been redirect to base URL slash main controller slash logout method this way we have said logout link also you but suppose any user directly access this page without login then it will execute else block of code [Music] so under this block we have right script tag and between this wave right window dot location is equal to slash method you now we have go to main controller and here we have create one more logout method for logging out from system under this block we have right off class with logout method this method will log out to user from application after this we have write returns statement with redirect method and under this we have right main controller name so after successfully logging out from system this code will redirect user to login page because in main controller index method his load login page after this we have go to login blade dot PHP page and here inform we have right action is equal to two curly bracket and between them we have right URL method with male controller slash check login method so when we have click on login button then it will send request to check login method of main controller for validate user login details now we want to set route logging success login method and logout method sir we have go-to web page P page under this page we have right root class with post method and under this we have right slash main slash check login and in second argument we have right main controller a check login method so when user have Phil login form and press login button then it will post form data to main controller check login method after success login into system we have redirect to success login method so here we have right root class with get method with two argument in first argument we have right slash main slash success login and in second argument we have right main controller at the rate success login so after success login into system then we have called success login method of main controller lastly we want to set root for logout so here we have write root class with get method with two argument like slash main slash logout and in second argument we have write main controller at logout method here when we have click on logout link then it will called logout method of main controller when we have login into system then we do not want to display login page we have go to login dot PHP view file here we have right at the rate if statement and under condition we have right is set function with auth class with user method with email if this condition true that means user has already login into system then we do not want to share this login page so it will execute if block of code under this block we have write script tag and between this we have write window dot location is equal to slash main slash success login so if login user want to access this login page after login then it will redirect to success login method of main controller so here our code is ready so we have not check output in browser friends when we have write base URL slash main controller then it load login page so here we have directly click on login button after clicking on login button we have received validation error on above login form so now we event - John Smith at gmail.com in email and password we have enter wrong password after this click on login button so after clicking on login button we have received our message like wrong user details error on webpage so here are validation code is working so now we have right John Smith at gmail.com in email and in password we have enter proper password and click on login button after clicking on button I URL redirect to mail slash success login and it display success login page with login user email it and logout link now we have removed success login from URL and press Center but after press enter page again redirect to success login URL that means when we have login into system then we cannot view login page after this now we have click on logout link and after clicking on logout link page has been redirect to login page now we have typed success login in URL and try to access welcome Paige but Paige has been again redirect to login page and we cannot access welcome page without login into system that means our login system working properly so this way we can make simple login system in laravel I hope you have learned something from this video tutorial if you have any query regarding this video tutorial part please comment your query in comment box and if you liked this video tutorial please share with your friends or even you can also share on social media also if you want to get more update regarding our video tutorial please subscribe our youtube channel forget more updates regarding release of future video lastly keep watching our youtube channel thanks for watching this video tutorial
Info
Channel: Webslesson
Views: 192,087
Rating: undefined out of 5
Keywords: login system, laravel login, login in laravel, laravel login tutorial, login system in laravel, laravel login system, laravel authentication tutorial, login user, laravel authentication, laravel login user, laravel auth, laravel login authentication, login form in laravel
Id: OUFmwAnFclo
Channel Id: undefined
Length: 24min 18sec (1458 seconds)
Published: Mon Mar 05 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.