<?php
namespace App\Notifications;
use App\Models\Comment;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
class NotifyWhenComment extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*/
public function __construct(public Comment $comment)
{
//
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['database'];
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
'comment_id' => $this->comment->id,
'comment_content' => $this->comment->content,
'user_avatar' => $this->comment->user->profile_photo_url,
'user_name' => $this->comment->user->name,
'feeling_id' => $this->comment->feeling->id,
'feeling_slug' => $this->comment->feeling->slug,
'feeling_title' => $this->comment->feeling->title,
];
}
}
<?php
namespace App\Notifications;
use App\Models\Comment;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
class NotifyWhenComment extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*/
public function __construct(public Comment $comment)
{
//
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['database'];
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
'comment_id' => $this->comment->id,
'comment_content' => $this->comment->content,
'user_avatar' => $this->comment->user->profile_photo_url,
'user_name' => $this->comment->user->name,
'feeling_id' => $this->comment->feeling->id,
'feeling_slug' => $this->comment->feeling->slug,
'feeling_title' => $this->comment->feeling->title,
];
}
}