Undefined property: App\Notifications\NewUserNotification::$id

Viewed 692

Show the Notification when the data is stored in the database, but when I want to create the Notification. This error occurs

  use Queueable;

    public $user;

   /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($user)
    {
        $this->user = $user;
    }

    public function via($notifiable)
    {
        return ['database'];
    }

    public function toDatabase($notifiable)
    {
        return [
            'name' => $this->user->name,
            'email' => $this->user->email,
        ];
    }
0 Answers
Related