在Laravel 5.3中找不到特征'Illuminate \ Foundation \ Auth \ AuthenticatesAndRegistersUsers'

时间:2016-09-23 07:41:15

标签: php laravel laravel-5.3

如何解决这个问题?我试图使用网络上的所有解决方案,我也尝试使用Illuminate \ Foundation \ Auth \ AuthenticatesAndRegistersUsers,但它们都没有工作?如果有人知道如何解决这个问题,请帮助我。我想摆脱这个错误。提前致谢

<?php

namespace App\Http\Controllers\Auth;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Illuminate\Support\Facades\Validator;   
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;

use Illuminate\Routing\Controller as BaseController;
use Theme;
use Auth;
use App\Login;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use App\Http\Controllers\Auth\RegisterController;
class LoginController extends BaseController
{

/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/

use AuthenticatesAndRegistersUsers, ThrottlesLogins;

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


/**
 * Create a new controller instance.
 *
 * @return void
 */

public function __construct()
{
    $this->middleware('guest', ['except' => 'logout']);
}


public function signin(){

    if(Auth::check()){

        return Redirect::to('/');

    }else{
        $theme = Theme::uses('default')->layout('default');
        return $theme->of('login.sign-in')->render();
    }

}



public function login(){


    $data = array(
        'email' => Input::get('email'),
        'password' => Input::get('password')
    );

   $validator= RegisterController::validator($data);

    if($validator){
        return Redirect::to('/login')->withErrors([$validator->errors()->all() ]);
    }else{
        return Redirect::to('/');
    }
}




      //  RegisterController::create($data);

       // Login::Insert($data);
      //  $checkuser = Login::Login($data);





function logout(){
    Auth::logout();
    return Redirect::to('login');
 }

 }

1 个答案:

答案 0 :(得分:8)

我认为Laravel 5.3软件包没有这个特性。请检查here

修改

由于在laravel 5.3中不再存在AuthenticatesAndRegistersUsers,您需要对新用户的验证和创建方式进行一些更改

所以你需要做出改变:

  

1 无需将Guard和Registrar实例传递给基础构造函数。完全从控制器的构造函数中删除这些依赖项。

     

2 无需使用Laravel 5.0中使用的App \ Services \ Registrar类,只需将此类中的验证器和create方法直接复制并粘贴到AuthController中。

确保在AuthController顶部导入Validator外观和用户模型。