Type error: Argument 1 passed to App\Http\Controllers\Auth\RegisterController::register() must be of the type array, object given

Posted 6 months ago by irankhosravi

What is this error?

Type error: Argument 1 passed to App\Http\Controllers\Auth\RegisterController::register() must be of the type array, object given

public function register(array $data, Request $request)
    {
        if ($request->hasFile('image')) {
            $fileNameWithExt = $request->file('image')->getClientOriginalName();
            $filename = pathinfo($fileNameWithExt, PATHINFO_FILENAME);
            $extention = $request->file('image')->getClientOriginalExtension();
            $fileNameToStore = $filename.'_'.time().'.'.$extention;
            $path = $request->file('image')->storeAs('public/images', $fileNameToStore);
        } else {
            $fileNameToStore = 'noimage.jpg';
        }

        return User::create([
            'firstname' => $data['firstـname'],
            'lastname' => $data['lastـname'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'mobile' => $data['mobile'],
            'nasional_code' => $data['national_code'],
            'birthdate' => $data['birthـdate'],
            'document' => $data['document'],
            'educational' => $data['educational'],
            'gender' => $data['gender'],
            'side' => $data['side'],
            $fileNameToStore => $data['image']
        ]);
    }

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.