Countries->find() ->contain(['Regions', 'Subregions']); $countries = $this->paginate($query); $this->set(compact('countries')); } /** * View method * * @param string|null $id Country id. * @return \Cake\Http\Response|null|void Renders view * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. */ public function view($id = null) { $country = $this->Countries->get($id, contain: ['Regions', 'Subregions', 'States']); $this->set(compact('country')); } }