VUE CODE
uploadFiles() {
let files = this.$refs.attachments.files;
for (let i = 0; i < files.length; i++) {
this.messageForm.attachments.push(files[i]);
}
}
и я получил массив файлов, в Vue Devtools
attachments: Array[3]
0: File
1: File
3: File
Как мне переименовать каждый файл и сохранить его в база данных в одном столбце как json формат
это то, что у меня есть, в моем контроллере
$files = [];
$attachments = $request['attachments'];
foreach ($attachments as $file) {
$file_ext = $file ?????????? ->getClientOriginalExtension();
$newname = uniqid(). "." . $file_ext;
$app = app();
$object = $app->make('stdClass');
$object->file = $newname;
array_push($files, $object);
}
$message = Message::create([
'sender_id' => auth('api')->user()->id,
'subject' => $request['subject'],
'content' => $request['content'],
'attachment' => $files
]);