Laravel Error: Specified key was too long error

When you run php artisan:migrate on Windows Machine and instead of Running the Migration, there is this error

[Illuminate\Database\QueryException]
    SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email))

    [PDOException]
    SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes 

Just put the following line in the register() method of app\Providers\AppServiceProvider.php


  

use Illuminate\Support\Facades\Schema;
 public function register()
    {
        Schema::defaultStringLength(191);
    }


 

And then run php artisan migrate

Note this problem is with older versions of MySql so you should rather upgrade your mysql installation rather then doing this hack.

Laravel 6 Custom Authentication Steps


Step 1) Install Laravel Authentication Package

composer require laravel/ui "^1.0" --dev

php artisan ui vue --auth

Step 2) Make Appropriate Changes to the User Model.

Step 3) Get Rid of Authentication Controller generated by Laravel.

Step 4) Create your own controller 1 for Login and 1 for Adding User

Step 5) You can use custom form requests to separate the Logic from the controller, for instance validation rules etc can be stored in the Form Request.

For E.g

php artisan make:request StoreUserRequest

Now you can pass StoreUserRequest to the Controller. For E.g

public function StoreUser(StoreUserRequest $request)

 

Step 5) Remember to Hash the Password before storing in the DB

  $password = Hash::make($request->password);

Step 6) Use Auth::attempt(['username']=>'WHATEVER OR $request->username','password'=>$request->password)  to Check for Valid User..

Step 7) Auth::User() should return the User anywhere in Views or Controller..




Running Drupal in Docker

I will assume that you have already installed docker. If you haven't installed docker please visit https://www.docker.com/ to download a...