Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Flex's avatar
Level 4

how to fix ErrorException: Undefined array key "name&quot in Laravel 10

working with Laravel 10 App and I have following RegisterController

public function store(Request $request)
    {
       $input = $request->all();

       User::create([
        'name' => $input['name'],  // this is line 18
        'email' => $input['email'],
        'password' => Hash::make($input['password'])
      ]);

          return response()->json(['status' => true,
                                    'message' => "Registation Success"   
        
        ]);
    }

api.php

Route::post('/register',[RegisterController::class, 'store']);

but when I try to test using postman post request for register I got following error msg ErrorException: Undefined array key "name" in file F:\2024\laravel + vue\back-app\app\Http\Controllers\RegisterController.php on line 18 how could I fix this?

0 likes
11 replies
enoch91's avatar

@flex you need to ensure that your request includes the name field

enoch91's avatar

@Flex kindly dump your request body using

dd($input);

Do this on line 16

Please or to participate in this conversation.