use App\Models\Comment;
use Illuminate\Notifications\Notification;
class YouWereMentionedNotification extends Notification
{
public $comment;
public function __construct(Comment $comment)
{
$this->comment = $comment;
}
public function via($notifiable)
{
return ['database'];
}
public function toArray($notifiable)
{
$topic = $this->comment->commentable;
$text = __(':creator mentioned you in :topic', [
'topic' => $topic->title,
'creator' => $notifiable->name,
]);
$url_prefix = get_class($topic) == 'App\Models\Task' ? 'tasks/' : 'leads/';
return [
'assigned_user' => $notifiable->id,
'created_user' => $this->comment->user_id,
'message' => $text,
'type' => get_class($topic),
'type_id' => $topic->id,
'url' => url($url_prefix . $topic->external_id),
'action' => 'mentioned'
];
}
}