2016-09-23 120 views
5

如何解决此问题?我alreay试图从网络中使用所有的解决方案,我也尝试使用Illuminate \ Foundation \ Auth \ AuthenticatesAndRegistersUsers,但他们都没有工作?如果有人知道如何解决这个问题,请帮助我。我想摆脱这个错误。在此先感谢在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'); 
} 

} 

回答

8

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

编辑:

你需要做出怎样的新用户进行验证,并因为AuthenticatesAndRegistersUsers造就了一些变化不复存在到laravel 5.3

所以,你需要做出改变:

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

无需使用Laravel 5.0中使用的App \ Services \ Registrar类,只需将您的验证器复制并粘贴到您的AuthController中即可。

确保在AuthController的顶部导入Validator facade和User模型。

+0

是的,我认为这是原因 – Paul

+0

@Paul:嗯看到可能编辑解决方案的帮助。 –

+0

谢谢先生:D – Paul

相关问题