$pageId) { Page::where('id', $pageId) ->where('sub_section_id', $subSectionId) ->update(['sort' => $index + 1]); } // Clear navigation cache since sort order changed Cache::forget('navigation'); // Clear page data cache for all pages in this subsection // so that section.pages relation is re-fetched with correct order $pages = Page::where('sub_section_id', $subSectionId)->get(); foreach ($pages as $page) { $cacheKey = 'page_data_' . md5($page->path); Cache::forget($cacheKey); } return true; }); } }