MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How to Create a Simple Login Authentication System in LARAVEL?Part-1

How to Create a Simple Login Authentication System in LARAVEL?

Firstly, we’ll create a new project for this.

Step 1. Go to XAMPP/htdocs folder -> right Click->Open Git Bash Here

Windows File Explorer open at the C:\xampp\htdocs folder
Right-click menu in the xampp htdocs folder with Git Bash Here selected

Step 2. To Create a New Project in Laravel, write down the following command:

$ composer create-project --prefer-dist laravel/laravel CustomerService "5.8.*"Code language: JavaScript (javascript)
Git Bash running composer create-project to make the Laravel 5.8 CustomerService project

Step 3. To Go the current working Project directory, write down this following command:

$ cd CustomerService

It’ll be redirected to the current Project.

Git Bash after cd CustomerService, now in the Laravel project directory

Mysql Database connection Laravel

Step 4. To Create a new Database so we have to Go to XAMPP server->phpMyAdmin->Click New Database-> customerservice.

PhpMyAdmin Create database form with the CustomerService database name entered

Step 5. Thereafter, Open Sublime Text and Go to .env file to set the current project path and give the project APP_URL path, DB_DATABASE name and DB_USERNAME name.

Laravel .env file in Sublime Text with APP_URL set to localhost/CustomerService/public
Laravel .env file in Sublime Text with DB_DATABASE set to CustomerService and DB_USERNAME to root

Step 6. To Migrate the user table which is in-built in database/migrations/ to Mysql database. Write down the following command:

$ php artisan migrate
Git Bash running php artisan migrate in the CustomerService project

Step 7.  To Insert user records in users table by use of Laravel seeders.  Write down the following command:


$ php artisan make:seeder UsersTablesSeeder
Git Bash terminal running php artisan make:seeder UsersTablesSeeders in the CustomerService project

Step 8. Now, Go to the database/seeds/UsersTablesSeeder.php and define single user data in the run() method.


       User::create([
            'name'    => 'Usha Kiran',
            'email'    => 'usha.cotocus@gmail.com',
            'password'   =>  Hash::make('password'),
            'remember_token' =>  str_random(10),
        ]);Code language: PHP (php)
Sublime Text showing UsersTablesSeeders.php run() method creating user Usha Kiran with a hashed password

Step 9. After that, Go to the database/seeds/DatabaseSeeder.php and call the UsersTablesSeeder.php class within the run() method.

DatabaseSeeder.php run() method calling Eloquent::unguard and the UsersTableSeeder class

Step 10. Here, we’ll Insert data into the UsersTablesSeeders. Write down the following command:

$ php artisan db:seeder
Terminal output of php artisan db:seed showing database seeding completed successfully

Inserted date into users table

PhpMyAdmin users table showing the seeded Usha Kiran record with a hashed password

Step 11. To Create a Controller in the app/Http/Controllers folder. Write down the following command:

$ php artisan make:controller MainController --resource
Terminal running php artisan make:controller MainController --resource with Controller created successfully

Step 12. After that, we need to load the login form, write this code within the index() method.

 public function index()
    {
        return view('login');
    }Code language: PHP (php)
MainController.php in Sublime Text with index() method returning the login view

Step 13. So, Create login.blade.php file in resources/views to display

Login.blade.php code with a Bootstrap form for email, password and a Login button

Step 14. Thereafter, Go to routes/web.php file and we’ll set route request.

Route::get('/login', 'MainController@index');Code language: PHP (php)
Routes/web.php with Route::get for /login pointing to MainController@index
Browser showing the Simple Login System in Laravel page with email and password fields
Login Page

Thanks

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

Todo Application in Laravel

1.Create Project in Laravel Composer create-project laravel/laravel todolist 2.Create CRUD Controller php artisan make:controller TodosController –resource 3.Route setup of CRUD Controller routes/web.php 4.Create Database todolist localhost/phpmyadmin create…

Read More

How to display a table in a Verticle or Horizontal form in the Laravel PHP Framework? Part-1

How to display a table in a Verticle or Horizontal form in the Laravel PHP Framework? How to Store Seed file into Database. Click There are two…

Read More

HOW TO CREATE EVENT CALENDAR IN LARAVEL? PART-3

Step 1.Create a Database in phpMyAdmin. (Write the same name of database which was written in .enf databse name). Step 2.  We use the migrate command to…

Read More

HOW TO CREATE EVENT CALENDAR IN LARAVEL? PART-2

Step 1.Create a Laravel Project Firstly, Create a new project in laravel, so we open Git Bash,  Go to My Computer/This PC–>LocalDisk(C:)–>Xampp–>Htdocs (Press right click on Mouse)…

Read More

CRUD Operations in Laravel PHP Framework

Step 1 – Download Laravel 5.8 In first step you have to download Laravel 5.8 version. For this you have to go to command prompt, in which…

Read More

How to file upload in DB With local folder using laravel 5.8

Step:1 you have to make these(A) – php artisan make:controller ImageUploadController(B) – php artisan make:model ImageUpload -m Step:2 Open the welcome.blade.php page then write this code. Step:3…

Read More