2017-02-16 5 views
0

私はヘルパーの助けを借りてユーザーを認証しようとしています この目的のために、私はアプリケーションディレクトリにヘルパーフォルダを作成しました。 App \プロバイダディレクトリにHelperServiceProvider.phpを作成し、その中に次のコードを使用EloquentUserProvider.php行Error 114:引数1がIlluminate Auth EloquentUserProvider :: validateCredentialsに渡されました

"files": [ 
     "app/Helpers/UserHelper.php" 
    ], 

composer.jsonに次のコード行を追加します。私は、これは私のUserモデルが

<?php 

    namespace App; 

    use Illuminate\Database\Eloquent\Model; 

    class User extends Model { 
    protected $table='users'; 
    protected $fillable =['username', 'password', 'firstname', 'lastname', 'email', 'phone', 'groupname', 'about', 'image']; 

    public static $login = [ 
    'username' => 'required|', 
    'email' => 'required|', 
    'password' => 'required' 
    ]; 
    } 

この私のUserHelper

<?php namespace App\Helpers; 
    use Illuminate\Support\Facades\Auth; 
    class UserHelper { 
    public static function processLogin($inputs){ 
    if(Auth::attempt($inputs)){ 
     return TRUE; 
    } else { 
     return FALSE; 
     } 
    } 
    } 
//this is an alias 
    'UserHelper' => App\Helpers\UserHelper::class, 
    //this is an provider 
    App\Providers\HelperServiceProvider::class, 

ある

のように提供app.phpにエイリアスを追加だけでなく、追加持たこの後

​​

ログイン機能はこちら

<?php 

    namespace App\Http\Controllers; 
    use App\User; 
    use Input; 
    use Illuminate\Support\Facades\Validator as Validator; 

    use App\Helpers\UserHelper; 


    class LoginController extends Controller 
    { 
    public function login() { 

    $inputs = Input::except('_token'); 
     $validator = Validator::make($inputs, User::$login); 

      if($validator->fails()){ 
        print_r($validator->errors()->first()); 
     } else { 
      $respones = \UserHelper::processLogin($inputs); 

     if($respones){ 
      return 'loginView'; 
      } else { 
      return 'not a user of our DB'; 
      } 
     } 
     } 
    } 

私も作者を更新しましたが、アプリケーションにログインした後にエラーが発生した場合、私は最後の5時間何か助けを探していますか?

Reards

+0

チェックアウトthis..https://laracasts.com/discuss/channels/laravel/fatalthrowableerror-while-attempting-to-authenticate – Sona

+0

ウェブサイトが今ダウンしている:( –

+0

なしyaar – Sona

答えて

1
In your code you are extending the class User extends Model but when you are using auth functionality in laravel you need to extend the auth rather than model.. 

Keep Illuminate\Foundation\Auth\User and extends the model like this... 

class User extends Authenticatable{ 
//code here 
} 
関連する問題