laravel 5.5 中的电子邮件通知我收到此错误```尝试访问 null 类型值的数组偏移量```

email notification in laravel 5.5 i get this error ```Trying to access array offset on value of type null```

我想在每次注册新用户时收到电子邮件通知,但是在创建 php artisan make:notification Taskcompleted 并在我的控制器中添加 Notification::route('mail','admin@gmail.com')->notify(new TaskCompleted()); 之后

public function store(Request $request){
        $employee = request()->validate([
            'employee_id' => 'required|max:250',
            'name' => 'required|max:100',
            'place_of_birth' => 'nullable|max:100',]);
Notification::route('mail','admin@gmail.com')->notify(new TaskCompleted());

我一直收到这个错误 Trying to access array offset on value of type null 我已经导入了必要的 class 并用 mailtrap 配置了我的 .env 文件,仍然有同样的错误

任务完成文件

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class TaskCompleted extends Notification
{
    use Queueable;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->line('The introduction to the notification.')
                    ->action('Notification Action', url('/'))
                    ->line('Thank you for using our application!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}

好的,我得到了我在 laravel 5.5 中使用 PHP 7.4 的解决方案,所以我将其降级为 PHP 7.2 现在可以正常工作了