当前位置: 首页 > 知识库问答 >
问题:

传递给Illumb\Auth\EloquentUserProvider::validateCredentials()的参数1必须是的实例

昌博易
2023-03-14

传递给Illumate\Auth\EloquentUserProvider的参数1::validateCreentials()必须是Illumate\合同\Auth\身份验证的实例,应用程序\模型\用户给定的实例,在D:\xampp\htdocs\后端\电子商务\供应商\laravel\框架\src\Illumate\Auth\SessionG中uard.php第384行----我有这个问题请帮我我的模特页


namespace App;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

我的控制器


namespace App\Http\Controllers;

use App\Mail\UserRegisterMail;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Mail;


class UserController extends Controller
{
    public function login(){
        return view('user.login');
    }

    public function register(){
        return view('user.register');
    }

    public function registerPost(Request $request){
        $request->validate([
            'ad' => 'required|max:60',
            'email' => 'required|email',
            'şifrə' => 'required|confirmed',
        ]);
        $request->flash();
        $user = User::create([
            'name' => $request->ad,
            'email' => $request->email,
            'password' => Hash::make($request->şifrə),
            'activation_code' => Str::random(60),
            'active' => 0
        ]);
        Mail::to($request->email)->send(new UserRegisterMail($user));
        // auth()->login($user,true);
        return redirect()->route('home');
    }

    public function activation($code){
        $user = User::where('activation_code',$code)->first();
        if(!is_null($user))
        {
            $user->activation_code = null;
            $user->active = 1;
            $user->save();
            return redirect()->to('/')->with('message','Qeydiyyatınız tamamlandı');
        }
    }

    public function loginPost(Request $request){
        $request->validate([
            'email'=>'required|email',
            'şifrə'=>'required'
        ]);
        if(Auth::attempt(['email'=>$request->email,'password'=>$request->şifrə],$request->has('xatirla')))
        {
            return redirect()->intended('/');
        }else{
            return redirect()->route('register');
        }
    }
}

共有1个答案

闻人杰
2023-03-14

将extends模型更改为extends Authenticatable。

在你的模型中

 类似资料: