20 lines
554 B
PHP
20 lines
554 B
PHP
<?php
|
|
|
|
namespace App\Filament\Support;
|
|
|
|
use App\Domain\Catalog\DomainRuleException;
|
|
use Filament\Notifications\Notification;
|
|
|
|
trait ReportsDomainRules
|
|
{
|
|
protected function report(callable $callback, string $success): void
|
|
{
|
|
try {
|
|
$detail = $callback();
|
|
Notification::make()->title(is_string($detail) && $detail !== '' ? $detail : $success)->success()->send();
|
|
} catch (DomainRuleException $exception) {
|
|
Notification::make()->title($exception->getMessage())->danger()->send();
|
|
}
|
|
}
|
|
}
|