pendingAttachments = $data['attachments'] ?? []; $this->pendingCollection = $data['attachment_collection'] ?? 'general'; unset($data['is_general'], $data['attachment_collection'], $data['attachments']); return $data; } protected function afterCreate(): void { $feedback = $this->getRecord(); $feedback->interactions()->create([ 'user_id' => auth()->id(), 'type' => 'note', 'content' => __('feedback.created_via', ['channel' => $feedback->feedbackChannel?->name ?? __('feedback.unknown_channel')]), 'changes' => ['status' => ['old' => null, 'new' => $feedback->status]], ]); 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), ]); } } }