Chinh sua giao dien phu hop tailwind css va upload
Some checks failed
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
Tests / PHP 8.5 (push) Has been cancelled

This commit is contained in:
2026-05-05 09:25:28 +00:00
parent 8c6b71cb8a
commit fb1f82e1a0
12 changed files with 834 additions and 466 deletions

View File

@@ -63,7 +63,7 @@ class EditFeedback extends EditRecord
FileUpload::make('transfer_attachments')
->label(__('app.attachments'))
->multiple()
->disk('local')
->disk('public')
->directory('feedback-attachments')
->columnSpanFull(),
])
@@ -82,13 +82,23 @@ class EditFeedback extends EditRecord
);
if (! empty($data['transfer_attachments'])) {
$fileService = App::make(FileService::class);
$fileService->upload(
$data['transfer_attachments'],
'general',
$feedback,
$sender->id,
);
$disk = Storage::disk('public');
foreach ($data['transfer_attachments'] as $path) {
if (! $disk->exists($path)) {
continue;
}
$feedback->attachments()->create([
'uuid' => (string) \Illuminate\Support\Str::uuid(),
'user_id' => $sender->id,
'name' => basename($path),
'path' => $path,
'disk' => 'public',
'collection' => 'general',
'mime_type' => $disk->mimeType($path),
'size' => $disk->size($path),
]);
}
}
Notification::make()
@@ -145,12 +155,19 @@ class EditFeedback extends EditRecord
return view('filament.resources.feedback.edit-footer');
}
protected array $pendingAttachments = [];
protected string $pendingCollection = 'general';
protected function mutateFormDataBeforeSave(array $data): array
{
if (($data['is_general'] ?? false) === true) {
$data['customer_product_id'] = null;
}
unset($data['is_general'], $data['attachment_collection']);
$this->pendingAttachments = $data['attachments'] ?? [];
$this->pendingCollection = $data['attachment_collection'] ?? 'general';
unset($data['is_general'], $data['attachment_collection'], $data['attachments']);
$newStatus = $data['status'] ?? null;
if ($newStatus === 'closed' && $this->getRecord()->status !== 'closed') {
@@ -163,24 +180,28 @@ class EditFeedback extends EditRecord
protected function afterSave(): void
{
$attachments = $this->data['attachments'] ?? [];
$collection = $this->data['attachment_collection'] ?? 'general';
if (empty($this->pendingAttachments)) {
return;
}
if (! empty($attachments)) {
$disk = Storage::disk('local');
$feedback = $this->getRecord();
foreach ($attachments as $path) {
$feedback->attachments()->create([
'uuid' => (string) \Illuminate\Support\Str::uuid(),
'user_id' => auth()->id(),
'name' => basename($path),
'path' => $path,
'disk' => 'local',
'collection' => $collection,
'mime_type' => $disk->mimeType($path),
'size' => $disk->size($path),
]);
$disk = Storage::disk('public');
$feedback = $this->getRecord();
foreach ($this->pendingAttachments as $path) {
if (! $disk->exists($path)) {
continue;
}
$feedback->attachments()->create([
'uuid' => (string) \Illuminate\Support\Str::uuid(),
'user_id' => auth()->id(),
'name' => basename($path),
'path' => $path,
'disk' => 'public',
'collection' => $this->pendingCollection,
'mime_type' => $disk->mimeType($path),
'size' => $disk->size($path),
]);
}
}