with('section') ->find($id); if (isset($page->section)) { $breadcrumbs = [ 'mainSection' => $page->section->mainSection->title, 'subSection' => $page->section->title, 'page' => $page->title, ]; } else { $breadcrumbs = null; } return response()->json([ 'data' => [ 'page' => new ClientPageNavigateResource($page), 'breadcrumbs' => $breadcrumbs ], ], 200); } }