46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\OperationRun;
|
|
use App\Models\PlatformUser;
|
|
use App\Models\Tenant;
|
|
use App\Support\OpsUx\OperationUxPresenter;
|
|
use App\Support\System\SystemOperationRunLinks;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class OperationRunCompleted extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(
|
|
public OperationRun $run
|
|
) {}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database'];
|
|
}
|
|
|
|
public function toDatabase(object $notifiable): array
|
|
{
|
|
$tenant = $this->run->tenant;
|
|
|
|
$notification = OperationUxPresenter::terminalDatabaseNotification(
|
|
run: $this->run,
|
|
tenant: $tenant instanceof Tenant ? $tenant : null,
|
|
);
|
|
|
|
if ($notifiable instanceof PlatformUser) {
|
|
$notification->actions([
|
|
\Filament\Actions\Action::make('view_run')
|
|
->label('View run')
|
|
->url(SystemOperationRunLinks::view($this->run)),
|
|
]);
|
|
}
|
|
|
|
return $notification->getDatabaseMessage();
|
|
}
|
|
}
|