Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
61 lines
1.9 KiB
PHP
61 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Support\ContentTypes;
|
|
use App\Support\ReviewTarget;
|
|
use Filament\Actions\Action;
|
|
use Filament\Notifications\Notification as FilamentNotification;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
/**
|
|
* Work sent back to whoever asked for the review.
|
|
*
|
|
* The half that is easy to forget to build, and the half that decides whether
|
|
* the review step gets used: an author who has to keep opening the panel to
|
|
* find out whether anybody looked will stop asking and go back to publishing
|
|
* things themselves — or to asking in a chat window, where it is not recorded.
|
|
*/
|
|
class ReviewReturned extends Notification
|
|
{
|
|
public function __construct(
|
|
public readonly Model $record,
|
|
public readonly string $note,
|
|
public readonly ?string $returnedBy = null,
|
|
) {}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database'];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toDatabase(object $notifiable): array
|
|
{
|
|
return FilamentNotification::make()
|
|
->title(__('panel.reviews.notification.returned', [
|
|
'name' => $this->returnedBy ?? __('panel.revisions.system'),
|
|
]))
|
|
// The reason travels with the notification rather than waiting
|
|
// behind a click: it is the entire content of the message.
|
|
->body(ContentTypes::title($this->record).' — '.$this->note)
|
|
->icon('heroicon-o-arrow-uturn-left')
|
|
->iconColor('danger')
|
|
->actions([
|
|
Action::make('open')
|
|
->label(__('panel.reviews.actions.open'))
|
|
->url(ReviewTarget::url($this->record))
|
|
->markAsRead(),
|
|
])
|
|
->getDatabaseMessage();
|
|
}
|
|
}
|