Error “Trying to access array offset on value of type null” laravel 5.8.26 Php 7.4.2

前端 未结 4 401
轮回少年
轮回少年 2021-01-13 01:23

I use below function for insert/create new user from admin panel:

public function store(Request $request)
{
    $this->validate($request, [
        \'name         


        
相关标签:
4条回答
  • 2021-01-13 01:38

    Change Your Php version in Composer.json to 7.4.1 and run

    composer update
    

    This works for me

    0 讨论(0)
  • 2021-01-13 01:53

    I have faced the same problem when I use laravel version 5.8.* and php version 7.4. I have solved this issue update composer. I just use this command in terminal

    php composer.phar update
    

    or

    composer update
    

    and fixed my issue easily.

    0 讨论(0)
  • 2021-01-13 01:53

    I was facing the same problem, after debugging I found my smtp credentials was not working properly, email sending modules was not working that why I was getting this error, after fixing the credentials my code starts working properly and exception get disappear.

    I suggest you to check your smtp credentials and make your you turn on less secure app setting.

    0 讨论(0)
  • 2021-01-13 01:55

    Try this Hope it will help You

    public function store(Request $request)
    {
        $this->validate($request, [
            'name' => 'required',
            'email' => 'required|email|unique:users,email',
            'password' => 'required|same:confirm-password'
        ]);
    
    
        $insert_array = [
                    'name' => $request->name,
                    'email' => $request->email,
                    'password' => Hash::make($request->password)
                ];
    
        User::create($insert_array );
    
        return redirect()->route('admin.pages.users.index')
            ->with('success','User created successfully');
    }
    
    0 讨论(0)
提交回复
热议问题