Laravel:尚未应用特质方法守卫,因为App Http Controllers Auther Aut



我正在更新到Laravel 5.4,并且正在收到此错误消息:

特征方法守卫尚未应用,因为在app http controllers auth authcontroller

上与其他特征方法发生了碰撞

这是我的authcontroller类。

<?php
namespace AppHttpControllersAuth;
use AppUser;
use Validator;
use AppHttpControllersController;
use IlluminateFoundationAuthThrottlesLogins;
use IlluminateFoundationAuthRegistersUsers;
use IlluminateFoundationAuthAuthenticatesUsers;
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 RegistersUsers, AuthenticatesUsers;
/**
 * 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 IlluminateContractsValidationValidator
 */
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']),
    ]);
}
}

我已更新:

use IlluminateFoundationAuthRegistersUsers;
use IlluminateFoundationAuthAuthenticatesUsers;

但是我100%确定错误消息的含义。

laravel内部使用特质 AuthenticatesAndRegistersUsers

因为这两个特征都共享了一些Laravel使用以下方法:

use AuthenticatesUsers, RegistersUsers {
    AuthenticatesUsers::redirectPath insteadof RegistersUsers;
    AuthenticatesUsers::guard insteadof RegistersUsers;
}

如果您这样做需要做出相同的决定(这里的决定很少,这两种方法都具有相同的目的(。

从那以后,Laravel当然将单个authcontroller分为2,从而消除了需要执行此操作的需要。

相关内容

  • 没有找到相关文章

最新更新