format('Y-m-d'); Storage::disk('public')->put($path . '/' . $date . '/' . $fullFileName, $image); Attachment::updateOrCreate( [ 'attachmentable_id' => $featureId, 'attachmentable_type' => $classModel, 'type' => $type, ], [ 'name' => $fileName, 'extension' => $extension, 'size' => strlen($image), ] ); } elseif ($file instanceof UploadedFile) { $date = now()->format('Y-m-d'); $extension = $file->getClientOriginalExtension(); $fileName = Str::uuid(); $file->storeAs($path . '/' . $date, $fileName . '.' . $extension, 'public'); Attachment::updateOrCreate( [ 'attachmentable_id' => $featureId, 'attachmentable_type' => $classModel, 'type' => $type, ], [ 'name' => $fileName, 'extension' => $extension, 'size' => $file->getSize(), ] ); } }); } }