php - 错误 "Trying to access array offset on value of type null"laravel 5.8.26 Php 7.4.2

标签 php laravel laravel-5

我使用以下功能从管理面板插入/创建新用户:

public function store(Request $request)
{
    $this->validate($request, [
        'name' => 'required',
        'email' => 'required|email|unique:users,email',
        'password' => 'required|same:confirm-password'
    ]);


    $input = $request->all();
    $input['password'] = Hash::make($input['password']);


    User::create($input);

    return redirect()->route('admin.pages.users.index')
        ->with('success','User created successfully');
}

当我提交时,我收到如下错误:-

Trying to access array offset on value of type null



编辑:
我发现了我的问题。我的问题是电子邮件验证规则。当我删除电子邮件验证插入数据是真的。

enter image description here

我该如何解决这个错误!

最佳答案

将 Composer.json 中的您的 PHP 版本更改为 7.4.1 并运行

composer update
这对我有用

关于php - 错误 "Trying to access array offset on value of type null"laravel 5.8.26 Php 7.4.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60188713/

相关文章:

Php exec Powershell 脚本 Azure AZ 命令不运行,所有其他功能都运行

php - 如何使用 PHP include 保留路径结构?

php - Laravel 和 MySQL 的唯一 IP 计数器

php - Laravel 5 + MongoDB

php - 我可以使用 Laravel 5 功能来保存每个公司每个用户的职位吗?

PHP 对来自 Aurora MySQL 的 JSON 编码数据失败

php - 如何通过更改通过引用传递的参数来对调用具有副作用的函数的方法进行单元测试?

php - Laravel 流明照亮/控制台不会更新

php - Laravel 在 PHPUnit 测试期间断言多个电子邮件收件人

mysql - 如何在 laravel 5 中对 Eloquent 关系执行包含子查询的更新