diff --git a/app/Traits/UploadAttachment.php b/app/Traits/UploadAttachment.php new file mode 100644 index 0000000..81c8299 --- /dev/null +++ b/app/Traits/UploadAttachment.php @@ -0,0 +1,29 @@ +format('Y-m-d'); + $extension = $file->getClientOriginalExtension(); + $fileName = Str::uuid(); + $file->storeAs($path.'/'.$date, $fileName.'.'.$extension, 'public'); + + Attachment::create([ + 'attachmentable_id' => $featureId, + 'attachmentable_type' => $classModel, + 'name' => $fileName, + 'extension' => $extension, + 'size' => $file->getSize(), + ]); + }); + } +}