dongpu2727 2017-02-16 12:02
浏览 122
已采纳

EloquentUserProvider.php第114行中的ErrorException:传递给Illuminate \ Auth \ EloquentUserProvider :: validateCredentials的参数1

I am trying to authenticate my user with the help of Helpers For this purpose i have make Helper folder in app directory. Add the following lines of code to the composer.json

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

Make HelperServiceProvider.php in App\Provider directory, and use the following code in it.

    <?php
    namespace App\Providers;
    use Illuminate\Support\ServiceProvider;

    class HelperServiceProvider extends ServiceProvider
    {
    /**
    * Bootstrap any application services.
    *
    * @return void
    */
    public function boot()
    {
    //
    }

    /**
    * Register any application services.
    *
    * @return void
    */
    public function register()
    {
    foreach (glob(app_path().'/Helpers/*.php') as $filename){
       require_once($filename);
    }

    }
    } 

after this i have add alias in app.php as well as add provide like this

    //this is an alias   
   'UserHelper' => App\Helpers\UserHelper::class,
    //this is an provider 
    App\Providers\HelperServiceProvider::class,

My User model is

   <?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'
   ];
   }

This my 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;
      }
     }
   }

Here is my Login Function

    <?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';
           } 
         }
       }
    }

I have also updated my composer and after i login to application following error comes up , i am searching this for last 5 hour any help ?

Reards

  • 写回答

1条回答 默认 最新

  • dsomm80482 2017-02-16 12:27
    关注
    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 
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿