如何解决laravel 5.5中的电子邮件通知我收到此错误`“试图访问类型为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
我已经导入了必要的类,并使用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可以正常工作
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。