/** * Updates the file ordering for a listing of attached files. * @param array $attachmentList * @param $pageId */ public function updateFileOrderWithinPage($attachmentList, $pageId) { foreach ($attachmentList as $index => $attachment) { Attachment::where('uploaded_to', '=', $pageId)->where('id', '=', $attachment['id'])->update(['order' => $index]); } }