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

Posted 8 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.

Reply to

Use Markdown with GitHub-flavored code blocks.