samedi 27 juillet 2019

Laravel 5.8 Illuminate\Auth\SessionGuard::login() error

Argument 1 passed to Illuminate\Auth\SessionGuard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of Illuminate\Http\RedirectResponse

I have my Register controller that checks if a membership id exists in a seperate member table before creating a login for a user. For existing membership Id it works fine but when a user enters a non existing Id I need it to redirect to the same login page with the error message. But all I get is the error above. Please not that I am using Illuminate\Foundation\Auth\User as Authenticatable in my user model and also my fillables are correct. Kindly help out.

protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => ['required', 'string', 'max:255'],
            'membership_id' => ['required', 'string', 'unique:users'],
            
        ]);
    }
    

  protected function create(array $data)
    {   
        $member = Member::where('member', '=', Input::get('membership_id'))->first();
        if($member){
            return User::create([
            'name' => $data['name'],
            'membership_id' => $data['membership_id'],
        ]);
        }elseif (!$member) {
            return \Redirect::back()->withErrors(['message' =>'Membership Id does not exist']);
        }
        
    }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire