@flex you need to ensure that your request includes the name field
Apr 4, 2024
11
Level 4
how to fix ErrorException: Undefined array key "name" 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?
Please or to participate in this conversation.