Skip to content

Commit c0a044d

Browse files
committed
Fix update position
1 parent 7c71e72 commit c0a044d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/behaviors/FileBehavior.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ private function bindMultiple($ownerId, $ownerType, $files)
382382
*/
383383
private function bindMultipleFile($file, $ownerId, $files)
384384
{
385+
$position = @array_search($file->id, array_keys($files)) + 1;
385386
if ($file->tmp) {
386387
$file->owner_id = $ownerId;
387388
$file->tmp = false;
@@ -390,10 +391,15 @@ private function bindMultipleFile($file, $ownerId, $files)
390391
'tmp' => $file->tmp,
391392
'owner_id' => $file->owner_id,
392393
'title' => @$files[$file->id],
393-
'position' => @array_search($file->id, array_keys($files)) + 1
394+
'position' => $position
394395
]);
395396
return true;
396397
}
398+
} else {
399+
$file->updateAttributes([
400+
'title' => @$files[$file->id],
401+
'position' => $position
402+
]);
397403
}
398404

399405
return false;

0 commit comments

Comments
 (0)