Add (facebook)
This commit is contained in:
41
app/Notifications/PostWasPublished.php
Normal file
41
app/Notifications/PostWasPublished.php
Normal 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]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user