Add (facebook)

This commit is contained in:
2023-11-21 03:10:27 +08:00
parent e0e13567d1
commit 4195aca2fe
8 changed files with 120 additions and 2 deletions

View File

@@ -0,0 +1,41 @@
<?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]));
}
}