问题描述
我使用以下功能从管理面板插入/创建新用户:
I use below function for insert/create new user from ***** panel:
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('*****.pages.users.index') ->with('success','User created successfully'); }
当我提交时出现如下错误:-
when I submit I get error as below :-
尝试访问类型为 null 的值的数组偏移
Trying to access array offset on value of type null
我发现了我的问题.我的问题是电子邮件验证规则.当我删除电子邮件验证插入数据是真的.
I found my problem. my problem is email validation rule. when i remove email validation insert data is true.
我该如何解决这个错误!
How do can i fix this error !
推荐答案
将 Composer.json 中的 PHP 版本更改为 7.4.1 并运行
Change Your Php version in Composer.json to 7.4.1 and run
composer update
这对我有用