Files
futurewalker/app/Notifications/PostWasPublished.php
2023-11-21 19:18:11 +08:00

39 lines
934 B
PHP

<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use NotificationChannels\FacebookPoster\FacebookPosterChannel;
use NotificationChannels\FacebookPoster\FacebookPosterPost;
class PostWasPublished extends Notification
{
use Queueable;
protected $post;
/**
* Create a new notification instance.
*/
public function __construct($post)
{
$this->post = $post;
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return [FacebookPosterChannel::class];
}
public function toFacebookPoster($notifiable)
{
return (new FacebookPosterPost(str_first_sentence($this->post->bites)))->withLink(route('front.post', ['slug' => $this->post->slug, 'category_slug' => $this->post->category->slug]));
}
}