42 lines
1003 B
PHP
42 lines
1003 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace CakeAddresses\Controller;
|
|
|
|
use CakeAddresses\Controller\AppController;
|
|
|
|
/**
|
|
* Countries Controller
|
|
*
|
|
* @property \CakeAddresses\Model\Table\CountriesTable $Countries
|
|
*/
|
|
class CountriesController extends AppController
|
|
{
|
|
/**
|
|
* Index method
|
|
*
|
|
* @return \Cake\Http\Response|null|void Renders view
|
|
*/
|
|
public function index()
|
|
{
|
|
$query = $this->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'));
|
|
}
|
|
}
|