Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trait 'Illuminate\Foundation\Auth\AuthenticatesUsers' not found on laravel 7x

Tags:

php

laravel

I cant understand why I am getting the above error when I navigate to the admin login page of my Laravel project. The Laravel version is 7x. How can i fix this?

enter image description here

<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;


class LoginController extends Controller
{
    use AuthenticatesUsers;

    /**
     * Where to redirect admins after login.
     *
     * @var string
     */
    protected $redirectTo = '/admin';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest:admin')->except('logout');
    }

    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function showLoginForm()
    {
        return view('admin.auth.login');
    }
}
like image 721
Wanjila Abraham Avatar asked May 01 '20 16:05

Wanjila Abraham


Video Answer


2 Answers

Ok if anyone has this error this is because of the following:

All authentication scaffolding has been moved to the laravel/ui repository. If you are using Laravel's authentication scaffolding, you should install the ^2.0 release of this package and the package should be installed in all environments.

So to resolve the error simply run the composer command on the root folder of the laravel application:

composer require laravel/ui "^2.0" 

Or simply run:

composer require laravel/ui 

Hope this helps.

like image 110
Sachin Bahukhandi Avatar answered Sep 21 '22 06:09

Sachin Bahukhandi


In a terminal window, execute this command:

composer require laravel/ui "^2.0" 

Then execute one of these commands (with your JS favorite framework):

Once the laravel/ui package has been installed, you may install the frontend scaffolding using the ui Artisan commands:

php artisan ui vue --auth 

Restart your local development environment and your code editor.

like image 33
Heterocigoto Avatar answered Sep 25 '22 06:09

Heterocigoto