20 lines
495 B
PHP
20 lines
495 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 {
|
|
$callback();
|
|
Notification::make()->title($success)->success()->send();
|
|
} catch (DomainRuleException $exception) {
|
|
Notification::make()->title($exception->getMessage())->danger()->send();
|
|
}
|
|
}
|
|
}
|