42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
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]));
|
|
}
|
|
}
|