mardi 25 août 2020

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

i want to get email notification each time a new user is registered but after creating php artisan make:notification Taskcompleted and added Notification::route('mail','admin@gmail.com')->notify(new TaskCompleted()); like this in my contoller

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());

i keep getting this error Trying to access array offset on value of type null i have imported the necessary class and configured my .env file with mailtrap,still yet same error

taskcompleted file

<?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 [
            //
        ];
    }
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire