update migrasi upload file to s3 amazon

This commit is contained in:
Server D3 Linksehat
2025-08-25 10:29:46 +07:00
parent ba2490147f
commit 633c9aeae0
7 changed files with 68 additions and 51 deletions

View File

@@ -128,15 +128,16 @@ class ChatController extends Controller
$pathFile = null;
if ($request->hasFile('file_chat')) {
foreach ($request->file_chat as $file) {
$pathFile = File::storeFile('chat', $message->id, $file);
$fileData = File::storeFile('chat', $message->id, $file);
File::updateOrCreate([
'fileable_type'=>'App\Models\Message',
'fileable_id' => $message->id,
'type' => 'chat',
'name' => File::getFileName('chat', $message->id, $file),
'name' => $fileData['name'],
'original_name' => $file->getClientOriginalName(),
'extension' => $file->getClientOriginalExtension(),
'path' => $pathFile,
'source' => env('FILESYSTEM_DISK'),
'path' => $fileData['path'],
'created_by' => auth()->user()->id,
'updated_by' => auth()->user()->id,
]);