Skip to content
pakainfo

Pakainfo

Web Development & Good Online education

  • Home
  • Blog
  • Categories
  • Tools
  • Full Form
  • Guest Post
    • Guest Posting Service
  • Advertise
  • About
  • Contact Us

Login Signup with Laravel

October 10, 2020 Pakainfo Laravel, Mysql, Mysqli, php Leave a comment

Today, We want to share with you laravel login and registration example.In this post we will show you laravel authentication tutorial, hear for laravel 5.4 login and registration tutorial we will give you demo and example for implement.In this post, we will learn about
Get Current login Auth user details using Laravel
with an example.

login register in laravel 7

Contents

  • login register in laravel 7
    • Step 1 laravel login and registration Auth
    • Step 2 Laravel model
    • Step 3 View File
    • Step 4 Laravel Controller
    • Summary
    • Related posts

There are the Following The simple About laravel 6 login and registration Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel 7 api authentication, so the laravel login without auth is used for this example is following below.

Step 1: laravel login and registration Auth

Execute php artisan make:auth in terminal.

php artisan make:auth

Execute php artisan migrate in terminal.

php artisan migrate

If you want customization( Adding username)

  1. First of all Execute php artisan make:auth in CMD using terminal.
  2. Open create_users_table.php migration file and included the bellow line
    $table->string(‘username’,191)->nullable()->unique();
  3. Execute php artisan migrate in CMD via terminal
  4. And then last step open RegisterController.php and included bellow line.

protected function validator(array $data)
{
        return Validator::make($data, [
            'name' => 'required|string|max:255',
            'username' => 'required|string|max:191|unique:users',
            'email' => 'required|string|email|max:191|unique:users',
            'password' => 'required|string|min:6|confirmed',
        ]);
}
protected function create(array $data)
{
    return User::create([
            'name' => $data['name'],
            'username' => $data['username'],
            'email' => $data['email'],
    'password' => bcrypt($data['password']),
    ]);
}

Step 2: Laravel model

User.php

protected $fillable = [
    'name', 'email', 'password','username',
];
    

Step 3: View File

resources/views/auth/register.blade.php

<div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
 <label for="username" class="col-md-4 control-label">Username</label>
 <div class="col-md-6">
   <input id="username" type="text" class="form-control" name="username" value="{{ old('username') }}" required>
        @if ($errors->has('username'))
            <span class="help-block">
                <strong>{{ $errors->first('username') }}</strong>
            </span>
        @endif
    </div>
</div>

Step 4: Laravel Controller

LoginController.php

use Illuminate\Http\Request;

protected function credentials(Request $request) 
{
    
    $field = filter_var($request->get($this->username()), FILTER_VALIDATE_EMAIL)
        ? $this->username()
        : 'username';

    return [
        $field => $request->get($this->username()),
        'password' => $request->password,
    ];
}

login.blade.php
Only update the type of Email field from email address to text and update custom label

 
<label for="email" class="col-md-4 control-label">E-Mail/Username</label>
<input id="email" type="text" class="form-control" name="email" value="{{ old('email') }}" required autofocus>

pages you want to get or fetch only after login then included the bellow laravel code in respective laravel controller files

public function __construct()
{
    $this->middleware('auth');
}

If you want to set admin and user custom session add bellow laravel code

protected function authenticated(Request $request, $user)
{
    $request->session()->put('admin', 'admin');
   return redirect()->intended($this->redirectPath());
}

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

Also Read This 👉   Laravel 5.6 Server Side Validation Example

I hope you get an idea about laravel login and registration example.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related posts:

  1. Laravel Custom Login Registration Example Tutorial
  2. laravel 8 login and registration example | Laravel 8 Auth
  3. Setup Laravel 6 Login Authentication
  4. Laravel 7 User Login Authentication From Scratch
  5. Get Current login Auth user details using Laravel 5.7
laravel 5.4 login and registration tutoriallaravel 6 login and registrationlaravel 7 api authenticationlaravel 7 login and registration examplelaravel authentication tutoriallaravel login and registration examplelaravel login without authlogin register in laravel 7

Post navigation

Previous Post:PHP MySQL: Querying fetch Data from Database
Next Post:Reset input fields using onchange event in JQuery

Advertise With Us

Increase visibility and sales with advertising. Let us promote you online.
Click Here

Write For Us

We’re accepting well-written informative guest posts and this is a great opportunity to collaborate.
Submit a guest post to [email protected]
Contact Us

Freelance web developer

Do you want to build a modern, lightweight, responsive website quickly?
Need a Website Or Web Application Contact : [email protected]
Note: Paid Service
Contact Me

Categories

3movierulz (64) Ajax (464) AngularJS (377) ASP.NET (61) Bio (109) Bollywood (108) Codeigniter (175) CSS (98) Earn Money (93) Education (63) Entertainment (130) fullform (87) Google Adsense (64) Highcharts (77) History (40) Hollywood (109) JavaScript (1359) Jobs (42) jQuery (1423) Laravel (1088) LifeStyle (53) movierulz4 (63) Mysql (1035) Mysqli (894) php (2133) Programming (2345) Python (99) Software (178) Software (90) Stories (98) tamilrockers (104) Tamilrockers kannada (64) Tamilrockers telugu (61) Tech (147) Technology (2416) Tips and Tricks (130) Tools (214) Top10 (505) Trading (94) Trending (76) VueJs (250) Web Technology (112) webtools (200) wordpress (166) World (343)

A To Z Full Forms

Access a complete full forms list with the meaning, definition, and example of the acronym or abbreviation.
Click Here
  • Home
  • About Us
  • Terms And Conditions
  • Write For Us
  • Advertise
  • Contact Us
  • Youtube Tag Extractor
  • Info Grepper
  • Guest Posting Sites
  • Increase Domain Authority
  • Social Media Marketing
  • Freelance web developer
  • Tools
Pakainfo 9-OLD, Ganesh Sco, Kothariya Ring Road, Chokadi, Rajkot - 360002 India
E-mail : [email protected]
Pakainfo

© 2023 Pakainfo. All rights reserved.

Top
Subscribe On YouTube : Download Source Code
We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype Guest Posting Sites