在laravel中的UserController中创建新用户时出现错误:array_key_exists()

问题描述 投票:0回答:1

我正在尝试在UserController中创建新用户,但出现错误。在Google上找不到任何帮助。

我试图禁用验证器,但仍然收到相同的错误。

$user = User::create([
   'name' => $name,
   'phone' => $phone,
   'email' => $email,
   'password' => Hash::make($password),
   'gym' => $gym,
   'user_role' => $user_role,
   'active' => $active
]);          

“ message”:“ array_key_exists():第一个参数应为字符串或整数”, “ exception”:“ ErrorException”, “文件”:

laravel api new-operator
1个回答
0
投票

就我而言,此行有错误

    $attrs = Attribute::get();
    $attribute_ids = $attrs->map->only(['id']); // solved

而不是

    $attrs = Attribute::get();
    $attribute_ids = $attrs->get(['id']); // here was my error

我先替换

和第二个无效

"message": "array_key_exists(): The first argument should be either a string or an integer",
"exception": "ErrorException",
© www.soinside.com 2019 - 2024. All rights reserved.