Solved: trying to access array offset on value of type null in Laravel 8

By | June 7, 2021

Today, I was working on a module that is being developed using Laravel, and I was creating the members history and, finally, trying to send them a notification email using Laravel Queue. And, when I was trying to dispatch the latest records, I was getting ‘Trying to access array offset on value of type null’ error.

This is my code:

$record = MemberHistories::updateOrCreate(['member_id' =>  $member->member_id, 'registration_date' => $member->registration_date], $update_data);
if($record) {
	SendMotificationMail::dispatch($record);
}

To fixed the issue, I googled and found that I have to run composer update command in order to solve the issue. And surprisingly, I did that and now the issue is resolved.

To fix trying to access array offset on value of type null error, run below command.

composer update

Or run this command

php composer.phar update