Chinh sua giao dien phu hop tailwind css va upload
This commit is contained in:
@@ -10,12 +10,19 @@ class CreateFeedback extends CreateRecord
|
||||
{
|
||||
protected static string $resource = FeedbackResource::class;
|
||||
|
||||
protected array $pendingAttachments = [];
|
||||
protected string $pendingCollection = 'general';
|
||||
|
||||
protected function mutateFormDataBeforeCreate(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']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -23,8 +30,6 @@ class CreateFeedback extends CreateRecord
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
$feedback = $this->getRecord();
|
||||
$attachments = $this->data['attachments'] ?? [];
|
||||
$collection = $this->data['attachment_collection'] ?? 'general';
|
||||
|
||||
$feedback->interactions()->create([
|
||||
'user_id' => auth()->id(),
|
||||
@@ -33,20 +38,27 @@ class CreateFeedback extends CreateRecord
|
||||
'changes' => ['status' => ['old' => null, 'new' => $feedback->status]],
|
||||
]);
|
||||
|
||||
if (! empty($attachments)) {
|
||||
$disk = Storage::disk('local');
|
||||
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),
|
||||
]);
|
||||
if (empty($this->pendingAttachments)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$disk = Storage::disk('public');
|
||||
|
||||
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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user