more fixes
This commit is contained in:
47
app/Notifications/StoryStatusNotification.php
Normal file
47
app/Notifications/StoryStatusNotification.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\Story;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class StoryStatusNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
private readonly Story $story,
|
||||
private readonly string $event,
|
||||
private readonly ?string $reason = null,
|
||||
) {
|
||||
}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['database'];
|
||||
}
|
||||
|
||||
public function toDatabase(object $notifiable): array
|
||||
{
|
||||
$message = match ($this->event) {
|
||||
'approved' => 'Your story "' . $this->story->title . '" was approved and published.',
|
||||
'rejected' => 'Your story "' . $this->story->title . '" was rejected. Update it and resubmit for review.',
|
||||
'published' => 'Your story "' . $this->story->title . '" is now published.',
|
||||
default => 'Story update: "' . $this->story->title . '" status changed.',
|
||||
};
|
||||
|
||||
return [
|
||||
'type' => 'story.' . $this->event,
|
||||
'story_id' => $this->story->id,
|
||||
'title' => $this->story->title,
|
||||
'slug' => $this->story->slug,
|
||||
'status' => $this->story->status,
|
||||
'reason' => $this->reason,
|
||||
'message' => $message,
|
||||
'url' => route('creator.stories.edit', ['story' => $this->story->id]),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user