Refactor: Enforce type safety, fix close deadlock, implement assignee restrictions and notify admin fallbacks
This commit is contained in:
@@ -177,6 +177,9 @@ class EditFeedback extends EditRecord
|
||||
|
||||
$newStatus = $data['status'] ?? null;
|
||||
if ($newStatus === 'closed' && $this->getRecord()->status !== 'closed') {
|
||||
// Save pending attachments first so ClosingService validation sees them
|
||||
$this->savePendingAttachments();
|
||||
|
||||
$closingService = App::make(ClosingService::class);
|
||||
$closingService->close($this->getRecord(), auth()->user());
|
||||
}
|
||||
@@ -184,7 +187,7 @@ class EditFeedback extends EditRecord
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function afterSave(): void
|
||||
protected function savePendingAttachments(): void
|
||||
{
|
||||
if (empty($this->pendingAttachments)) {
|
||||
return;
|
||||
@@ -213,6 +216,13 @@ class EditFeedback extends EditRecord
|
||||
'size' => $this->safeFileSize($disk, $path),
|
||||
]);
|
||||
}
|
||||
|
||||
$this->pendingAttachments = []; // Clear to prevent double saving in afterSave
|
||||
}
|
||||
|
||||
protected function afterSave(): void
|
||||
{
|
||||
$this->savePendingAttachments();
|
||||
}
|
||||
|
||||
protected function safeMimeType($disk, string $path): ?string
|
||||
|
||||
@@ -59,7 +59,25 @@ class FeedbackForm
|
||||
)
|
||||
->visible(fn ($get): bool => ! $get('is_general'))
|
||||
->nullable()
|
||||
->live(),
|
||||
->live()
|
||||
->afterStateUpdated(function ($state, $set): void {
|
||||
if (empty($state)) {
|
||||
$set('contract_id', null);
|
||||
return;
|
||||
}
|
||||
$cp = CustomerProduct::find($state);
|
||||
if (! $cp) {
|
||||
return;
|
||||
}
|
||||
$activeContract = \App\Models\Contract::where('product_id', $cp->product_id)
|
||||
->where('status', 'active')
|
||||
->first();
|
||||
if ($activeContract) {
|
||||
$set('contract_id', $activeContract->id);
|
||||
} else {
|
||||
$set('contract_id', null);
|
||||
}
|
||||
}),
|
||||
|
||||
Select::make('contract_id')
|
||||
->label(__('app.contract'))
|
||||
|
||||
Reference in New Issue
Block a user