Laravel:找不到特质'Illuminate \ Foundation \ Auth \ AuthenticatesAndRegistersUsers' [英] Laravel: Trait 'Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers' not found
问题描述
我正在更新到Laravel 5.4,并在尝试显示登录屏幕时收到以下错误消息.
I'm updating to Laravel 5.4 and am receiving the following error message when trying to display the login screen.
我收到以下错误消息:
找不到特质'Illuminate \ Foundation \ Auth \ AuthenticatesAndRegistersUsers'
Trait 'Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers' not found
这是AuthController类:
Here's is the AuthController class:
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Where to redirect users after logout.
*
* @var string
*/
protected $redirectAfterLogout = '/login';
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => ['getLogout']]);
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
推荐答案
使用laravel 5.4,我们在此特征上有一些更改.现在我们有两个不同的特征:
with laravel 5.4 we have some changes in this trait. Now we have two different traits:
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
如果您安装了一个新的5.4 laravel应用程序,您将看到现在有了LoginController和RegisterController而不是AuthController
And if you install a fresh 5.4 laravel application you will see that now you have LoginController and RegisterController instead of AuthController
这篇关于Laravel:找不到特质'Illuminate \ Foundation \ Auth \ AuthenticatesAndRegistersUsers'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!