Version 2.0

This commit is contained in:
2026-05-12 09:23:05 +00:00
parent f2bc048219
commit f1b68e5e78
34 changed files with 564 additions and 283 deletions

View File

@@ -3,9 +3,38 @@
namespace App\Filament\Resources\Contracts\Pages;
use App\Filament\Resources\Contracts\ContractResource;
use App\Models\Contract;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\CreateRecord;
class CreateContract extends CreateRecord
{
protected static string $resource = ContractResource::class;
protected function mutateFormDataBeforeCreate(array $data): array
{
if (($data['status'] ?? '') === 'active') {
$existing = Contract::where('product_id', $data['product_id'])
->where('category', $data['category'])
->where('status', 'active')
->first();
if ($existing) {
Notification::make()
->title(__('feedback.contract_duplicate_title', [
'category' => \App\Enums\ContractCategory::from($data['category'])->label(),
]))
->body(__('feedback.contract_duplicate_body', [
'product' => $existing->product?->name ?? '?',
'customer' => $existing->customer?->name ?? '?',
]))
->warning()
->send();
$this->halt();
}
}
return $data;
}
}