Nosean
7 months ago

After Register

Posted 7 months ago by Nosean

Hi Guys,

After registering, I receive the following error message. Have changed the create () method to my liking. how can I solve the problem ?

Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, null given, called in C:\xampp\htdocs\agramarket\vendor\laravel\framework\src\Illuminate\Foundation\Auth\RegistersUsers.php on line 35

my registercontroller:

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;

class RegisterController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */

    use RegistersUsers;

    /**
     * Where to redirect users after registration.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'firmaname' => ['string', 'max:255'],
            'anrede' => ['required', 'string', 'max:5'],
            'name1' => ['required', 'string', 'max:255'],
            'strasse' => ['required', 'string', 'max:255'],
            'plz' => ['required', 'string', 'max:10'],
            'ort' => ['required', 'string', 'max:255'],
            'land_id' => ['required'],
            'name' => ['required','string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password1' => ['required', 'string', 'min:6'],
            'password2' => 'required|min:8|same:password1',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\User
     */
    protected function create(array $data)
    {
            User::create([
            'firmaname' => $data['firmaname'],
            'haendler' => 'nein',
            'anrede' => $data['anrede'],
            'name' => $data['name'],
            'strasse' => $data['strasse'],
            'plz' => $data['plz'],
            'ort' => $data['ort'],
            'land_id' => $data['land_id'],
            'name1' => $data['name1'],
            'email' => $data['email'],
            'password' => Hash::make($data['password1'])
        ]);

    }
}

Thx for help

Please sign in or create an account to participate in this conversation.