feat: partial payment field + photo upload from dashboard

- WorkOrderResource: pay_status is now live(); added _partial_amount
  TextInput (visible only when pay_status=partial) that shows current
  paid amount and accepts a new total — dehydrated so it does not save
  directly; _achitat hidden when partial is selected to avoid confusion
- EditWorkOrder.afterSave: creates a Payment record for the difference
  when pay_status=partial and entered amount > existing paidAmount
- WorkOrderDashboard: WithFileUploads + uploadPhotos / deletePhoto
  methods using Spatie MediaLibrary
- Dashboard blade: Foto tab replaced with upload form + gallery with
  per-photo delete buttons

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-08 08:16:21 +00:00
parent aa231f4b08
commit 1e7ca0fdfe
4 changed files with 83 additions and 4 deletions
@@ -4,6 +4,7 @@ namespace App\Filament\Tenant\Pages;
use App\Models\Tenant\WorkOrder;
use Filament\Pages\Page;
use Livewire\WithFileUploads;
/**
* Mitchell1-style 3-column dashboard view for a single WorkOrder.
@@ -12,6 +13,8 @@ use Filament\Pages\Page;
*/
class WorkOrderDashboard extends Page
{
use WithFileUploads;
protected static string|\BackedEnum|null $navigationIcon = null;
protected static bool $shouldRegisterNavigation = false;
@@ -191,6 +194,32 @@ class WorkOrderDashboard extends Page
->get();
}
public array $newPhotos = [];
public function uploadPhotos(): void
{
$this->validate(['newPhotos.*' => 'image|max:15360']);
foreach ($this->newPhotos as $photo) {
$this->record->addMedia($photo->getRealPath())
->usingFileName($photo->getClientOriginalName())
->toMediaCollection('photos');
}
$this->newPhotos = [];
$this->record->refresh();
\Filament\Notifications\Notification::make()
->title(__('Fotografii adăugate'))
->success()->send();
}
public function deletePhoto(int $mediaId): void
{
$media = $this->record->getMedia('photos')->firstWhere('id', $mediaId);
if ($media && (int) $media->model_id === $this->record->id) {
$media->delete();
$this->record->refresh();
}
}
public string $newMessage = '';
public function sendMessage(): void