first standalone plugin commit

This commit is contained in:
Brandon Shipley 2025-11-18 00:43:34 -08:00
commit 5dc7aa87cd
Signed by: bmfs
GPG Key ID: 14E38571D8BB0DE4
86 changed files with 86844 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
/composer.lock
/composer.phar
/phpunit.xml
/.phpunit.result.cache
/phpunit.phar
/config/Migrations/schema-dump-default.lock
/vendor/
/.idea/
/tmp

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# CakeAddresses plugin for CakePHP
## Installation
You can install this plugin into your CakePHP application using [composer](https://getcomposer.org).
The recommended way to install composer packages is:
```
composer require hi-powered-dev/cake-addresses
```

30
composer.json Normal file
View File

@ -0,0 +1,30 @@
{
"name": "hi-powered-dev/cake-addresses",
"description": "CakeAddresses plugin for CakePHP",
"type": "cakephp-plugin",
"license": "MIT",
"require": {
"php": ">=8.1",
"cakephp/cakephp": "^5.0.1"
},
"require-dev": {
"phpunit/phpunit": "^10.1",
"php-collective/decimal-object": "^1.3",
"cakephp/migrations": "^4.0.0"
},
"suggest": {
"dereuromark/cakephp-geo": "^3.2"
},
"autoload": {
"psr-4": {
"CakeAddresses\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"CakeAddresses\\Test\\": "tests/",
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/",
"TestApp\\": "tests/test_app/src/"
}
}
}

View File

@ -0,0 +1,605 @@
<?php
declare(strict_types=1);
use Migrations\AbstractMigration;
class InitialAddresses extends AbstractMigration
{
/**
* Up Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-up-method
* @return void
*/
public function up(): void
{
$this->table('addresses')
->addColumn('address_name', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('contact_name', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('address_line1', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
])
->addColumn('address_line2', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('city', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
])
->addColumn('city_id', 'integer', [
'default' => null,
'limit' => null,
'null' => true,
'signed' => true,
])
->addColumn('state', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
])
->addColumn('state_id', 'integer', [
'default' => null,
'limit' => null,
'null' => true,
'signed' => true,
])
->addColumn('postal_code', 'string', [
'default' => null,
'limit' => 25,
'null' => false,
])
->addColumn('country', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
])
->addColumn('country_id', 'integer', [
'default' => null,
'limit' => null,
'null' => true,
'signed' => true,
])
->addColumn('phone_number', 'string', [
'default' => null,
'limit' => 25,
'null' => true,
])
->addColumn('email', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('notes', 'text', [
'default' => null,
'limit' => null,
'null' => true,
])
->create();
$this->table('cities')
->addColumn('name', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
])
->addColumn('state_id', 'integer', [
'default' => null,
'limit' => null,
'null' => false,
'signed' => false,
])
->addColumn('state_code', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
])
->addColumn('country_id', 'integer', [
'default' => null,
'limit' => null,
'null' => false,
'signed' => false,
])
->addColumn('country_code', 'char', [
'default' => null,
'limit' => 2,
'null' => false,
])
->addColumn('latitude', 'decimal', [
'default' => null,
'null' => false,
'precision' => 10,
'scale' => 8,
'signed' => true,
])
->addColumn('longitude', 'decimal', [
'default' => null,
'null' => false,
'precision' => 11,
'scale' => 8,
'signed' => true,
])
->addColumn('created_at', 'timestamp', [
'default' => '2014-01-01 14:31:01',
'limit' => null,
'null' => false,
])
->addColumn('updated_at', 'timestamp', [
'default' => '2014-01-01 14:31:01',
'limit' => null,
'null' => false,
])
->addColumn('flag', 'boolean', [
'default' => true,
'limit' => null,
'null' => false,
])
->addColumn('wikiDataId', 'string', [
'comment' => 'Rapid API GeoDB Cities',
'default' => null,
'limit' => 255,
'null' => true,
])
// ->addIndex(
// [
// 'state_id',
// ],
// [
// 'name' => 'cities_test_ibfk_1',
// ]
// )
// ->addIndex(
// [
// 'country_id',
// ],
// [
// 'name' => 'cities_test_ibfk_2',
// ]
// )
->create();
$this->table('countries')
->addColumn('name', 'string', [
'default' => null,
'limit' => 100,
'null' => false,
])
->addColumn('iso3', 'char', [
'default' => null,
'limit' => 3,
'null' => true,
])
->addColumn('numeric_code', 'char', [
'default' => null,
'limit' => 3,
'null' => true,
])
->addColumn('iso2', 'char', [
'default' => null,
'limit' => 2,
'null' => true,
])
->addColumn('phonecode', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('capital', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('currency', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('currency_name', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('currency_symbol', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('tld', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('native', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('region', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('region_id', 'integer', [
'default' => null,
'limit' => null,
'null' => true,
'signed' => false,
])
->addColumn('subregion', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('subregion_id', 'integer', [
'default' => null,
'limit' => null,
'null' => true,
'signed' => false,
])
->addColumn('nationality', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('timezones', 'text', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('translations', 'text', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('latitude', 'decimal', [
'default' => null,
'null' => true,
'precision' => 10,
'scale' => 8,
'signed' => true,
])
->addColumn('longitude', 'decimal', [
'default' => null,
'null' => true,
'precision' => 11,
'scale' => 8,
'signed' => true,
])
->addColumn('emoji', 'string', [
'default' => null,
'limit' => 191,
'null' => true,
])
->addColumn('emojiU', 'string', [
'default' => null,
'limit' => 191,
'null' => true,
])
->addColumn('created_at', 'timestamp', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('updated_at', 'timestamp', [
'default' => '2014-01-01 14:31:01',
'limit' => null,
'null' => false,
])
->addColumn('flag', 'boolean', [
'default' => true,
'limit' => null,
'null' => false,
])
->addColumn('wikiDataId', 'string', [
'comment' => 'Rapid API GeoDB Cities',
'default' => null,
'limit' => 255,
'null' => true,
])
->addIndex(
[
'region_id',
],
[
'name' => 'country_continent',
]
)
->addIndex(
[
'subregion_id',
],
[
'name' => 'country_subregion',
]
)
->create();
$this->table('regions')
->addColumn('name', 'string', [
'default' => null,
'limit' => 100,
'null' => false,
])
->addColumn('translations', 'text', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('created_at', 'timestamp', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('updated_at', 'timestamp', [
'default' => '2014-01-01 14:31:01',
'limit' => null,
'null' => false,
])
->addColumn('flag', 'boolean', [
'default' => true,
'limit' => null,
'null' => false,
])
->addColumn('wikiDataId', 'string', [
'comment' => 'Rapid API GeoDB Cities',
'default' => null,
'limit' => 255,
'null' => true,
])
->create();
$this->table('states')
->addColumn('name', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
])
->addColumn('country_id', 'integer', [
'default' => null,
'limit' => null,
'null' => false,
'signed' => false,
])
->addColumn('country_code', 'char', [
'default' => null,
'limit' => 2,
'null' => false,
])
->addColumn('fips_code', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('iso2', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('type', 'string', [
'default' => null,
'limit' => 191,
'null' => true,
])
->addColumn('latitude', 'decimal', [
'default' => null,
'null' => true,
'precision' => 10,
'scale' => 8,
'signed' => true,
])
->addColumn('longitude', 'decimal', [
'default' => null,
'null' => true,
'precision' => 11,
'scale' => 8,
'signed' => true,
])
->addColumn('created_at', 'timestamp', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('updated_at', 'timestamp', [
'default' => '2014-01-01 14:31:01',
'limit' => null,
'null' => false,
])
->addColumn('flag', 'boolean', [
'default' => true,
'limit' => null,
'null' => false,
])
->addColumn('wikiDataId', 'string', [
'comment' => 'Rapid API GeoDB Cities',
'default' => null,
'limit' => 255,
'null' => true,
])
->addIndex(
[
'country_id',
],
[
'name' => 'country_region',
]
)
->create();
$this->table('subregions')
->addColumn('name', 'string', [
'default' => null,
'limit' => 100,
'null' => false,
])
->addColumn('translations', 'text', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('region_id', 'integer', [
'default' => null,
'limit' => null,
'null' => false,
'signed' => false,
])
->addColumn('created_at', 'timestamp', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('updated_at', 'timestamp', [
'default' => '2014-01-01 14:31:01',
'limit' => null,
'null' => false,
])
->addColumn('flag', 'boolean', [
'default' => true,
'limit' => null,
'null' => false,
])
->addColumn('wikiDataId', 'string', [
'comment' => 'Rapid API GeoDB Cities',
'default' => null,
'limit' => 255,
'null' => true,
])
->addIndex(
[
'region_id',
],
[
'name' => 'subregion_continent',
]
)
->create();
// $this->table('cities')
// ->addForeignKey(
// 'country_id',
// 'countries',
// 'id',
// [
// 'update' => 'RESTRICT',
// 'delete' => 'RESTRICT',
// 'constraint' => 'cities_ibfk_2'
// ]
// )
// ->addForeignKey(
// 'state_id',
// 'states',
// 'id',
// [
// 'update' => 'RESTRICT',
// 'delete' => 'RESTRICT',
// 'constraint' => 'cities_ibfk_1'
// ]
// )
// ->update();
// $this->table('countries')
// ->addForeignKey(
// 'subregion_id',
// 'subregions',
// 'id',
// [
// 'update' => 'RESTRICT',
// 'delete' => 'RESTRICT',
// 'constraint' => 'country_subregion_final'
// ]
// )
// ->addForeignKey(
// 'region_id',
// 'regions',
// 'id',
// [
// 'update' => 'RESTRICT',
// 'delete' => 'RESTRICT',
// 'constraint' => 'country_continent_final'
// ]
// )
// ->update();
// $this->table('states')
// ->addForeignKey(
// 'country_id',
// 'countries',
// 'id',
// [
// 'update' => 'RESTRICT',
// 'delete' => 'RESTRICT',
// 'constraint' => 'country_region_final'
// ]
// )
// ->update();
//
// $this->table('subregions')
// ->addForeignKey(
// 'region_id',
// 'regions',
// 'id',
// [
// 'update' => 'RESTRICT',
// 'delete' => 'RESTRICT',
// 'constraint' => 'subregion_continent_final'
// ]
// )
// ->update();
}
/**
* Down Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-down-method
* @return void
*/
public function down(): void
{
$this->table('cities')
->dropForeignKey(
'country_id'
)
->dropForeignKey(
'state_id'
)->save();
$this->table('countries')
->dropForeignKey(
'subregion_id'
)
->dropForeignKey(
'region_id'
)
->save();
$this->table('states')
->dropForeignKey(
'country_id'
)->save();
$this->table('subregions')
->dropForeignKey(
'region_id'
)->save();
$this->table('addresses')->drop()->save();
$this->table('cities')->drop()->save();
$this->table('countries')->drop()->save();
$this->table('regions')->drop()->save();
$this->table('states')->drop()->save();
$this->table('subregions')->drop()->save();
}
}

9
config/app.example.php Normal file
View File

@ -0,0 +1,9 @@
<?php
// The following configs can be globally configured, copy the array content over to your ROOT/config
return [
'CakeAddresses' => [
],
];

14
config/routes.php Normal file
View File

@ -0,0 +1,14 @@
<?php
use Cake\Routing\Route\DashedRoute;
$routes->plugin(
'CakeAddresses',
['path' => '/address-manager'],
function ($routes) {
$routes->setRouteClass(DashedRoute::class);
$routes->connect('/addresses', ['controller' => 'Addresses', 'action' => 'index']);
$routes->connect('/addresses/view/{id}', ['controller' => 'Addresses', 'action' => 'view', ], ['id' => '\d+', 'pass' => ['id']]);
$routes->connect('/addresses/edit/{id}', ['controller' => 'Addresses', 'action' => 'update'], ['id' => '\d+', 'pass' => ['id']]);
$routes->connect('/addresses/add', ['controller' => 'Addresses', 'action' => 'add']);
}
);

31
phpunit.xml.dist Normal file
View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
<env name="FIXTURE_SCHEMA_METADATA" value="tests/schema.php"/>
</php>
<!-- Add any additional test suites you want to run here -->
<testsuites>
<testsuite name="CakeAddresses">
<directory>tests/TestCase/</directory>
</testsuite>
</testsuites>
<!-- Setup fixture extension -->
<extensions>
<bootstrap class="Cake\TestSuite\Fixture\Extension\PHPUnitExtension"/>
</extensions>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>

View File

@ -0,0 +1,93 @@
<?php
declare(strict_types=1);
namespace CakeAddresses;
use Cake\Console\CommandCollection;
use Cake\Core\BasePlugin;
use Cake\Core\ContainerInterface;
use Cake\Core\PluginApplicationInterface;
use Cake\Http\MiddlewareQueue;
use Cake\Routing\RouteBuilder;
/**
* Plugin for CakeAddresses
*/
class CakeAddressesPlugin extends BasePlugin
{
/**
* Load all the plugin configuration and bootstrap logic.
*
* The host application is provided as an argument. This allows you to load
* additional plugin dependencies, or attach events.
*
* @param \Cake\Core\PluginApplicationInterface $app The host application
* @return void
*/
public function bootstrap(PluginApplicationInterface $app): void
{
}
/**
* Add routes for the plugin.
*
* If your plugin has many routes and you would like to isolate them into a separate file,
* you can create `$plugin/config/routes.php` and delete this method.
*
* @param \Cake\Routing\RouteBuilder $routes The route builder to update.
* @return void
*/
public function routes(RouteBuilder $routes): void
{
$routes->plugin(
'CakeAddresses',
['path' => '/cake-addresses'],
function (RouteBuilder $builder) {
// Add custom routes here
$builder->fallbacks();
}
);
parent::routes($routes);
}
/**
* Add middleware for the plugin.
*
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to update.
* @return \Cake\Http\MiddlewareQueue
*/
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
{
// Add your middlewares here
return $middlewareQueue;
}
/**
* Add commands for the plugin.
*
* @param \Cake\Console\CommandCollection $commands The command collection to update.
* @return \Cake\Console\CommandCollection
*/
public function console(CommandCollection $commands): CommandCollection
{
// Add your commands here
$commands = parent::console($commands);
return $commands;
}
/**
* Register application container services.
*
* @param \Cake\Core\ContainerInterface $container The Container to update.
* @return void
* @link https://book.cakephp.org/4/en/development/dependency-injection.html#dependency-injection
*/
public function services(ContainerInterface $container): void
{
// Add your services here
}
}

View File

@ -0,0 +1,110 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Controller;
use Cake\Log\Log;
use CakeAddresses\Controller\AppController;
/**
* Addresses Controller
*
* @property \CakeAddresses\Model\Table\AddressesTable $Addresses
*/
class AddressesController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|null|void Renders view
*/
public function index()
{
$query = $this->Addresses->find()
->contain(['Cities', 'States', 'Countries']);
$addresses = $this->paginate($query);
$this->set(compact('addresses'));
}
/**
* View method
*
* @param string|null $id Address id.
* @return \Cake\Http\Response|null|void Renders view
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$address = $this->Addresses->get($id, contain: ['Cities', 'States', 'Countries']);
$this->set(compact('address'));
}
/**
* Add method
*
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
*/
public function add()
{
$address = $this->Addresses->newEmptyEntity();
if ($this->request->is('post')) {
$data = $this->request->getData();
$address = $this->Addresses->patchEntity($address, $data);
if ($this->Addresses->save($address)) {
$this->Flash->success(__('The address has been saved.'));
return $this->redirect(['action' => 'index']);
}
Log::alert(print_r('$address->getErrors() from addresses add', true));
Log::alert(print_r($address->getErrors(), true));
$this->Flash->error(__('The address could not be saved. Please, try again.'));
}
$countries = $this->Addresses->Countries->find('list')->all();
$this->set(compact('address', 'countries'));
}
/**
* Edit method
*
* @param string|null $id Address id.
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function edit($id = null)
{
$address = $this->Addresses->get($id, contain: []);
if ($this->request->is(['patch', 'post', 'put'])) {
$address = $this->Addresses->patchEntity($address, $this->request->getData());
if ($this->Addresses->save($address)) {
$this->Flash->success(__('The address has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The address could not be saved. Please, try again.'));
}
$countries = $this->Addresses->Countries->find('list')->all();
$states = $this->Addresses->States->find('list')->where(['country_id' => $address->country_id])->all();
$this->set(compact('address', 'countries', 'states'));
}
/**
* Delete method
*
* @param string|null $id Address id.
* @return \Cake\Http\Response|null Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$address = $this->Addresses->get($id);
if ($this->Addresses->delete($address)) {
$this->Flash->success(__('The address has been deleted.'));
} else {
$this->Flash->error(__('The address could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Controller;
use App\Controller\AppController as BaseController;
class AppController extends BaseController
{
}

View File

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Controller;
use CakeAddresses\Controller\AppController;
/**
* Cities Controller
*
* @property \CakeAddresses\Model\Table\CitiesTable $Cities
*/
class CitiesController extends AppController
{
/**
* @return \Cake\Http\Response|null|void Renders view
*/
public function select()
{
$query = $this->Cities
// ->find('search', $this->request->getQueryParams())
->find('list')
->orderBy(['name']);
$cities = $this->paginate($query);
$this->set(compact('cities'));
}
}

View File

@ -0,0 +1,41 @@
<?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'));
}
}

View File

@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Controller;
use CakeAddresses\Controller\AppController;
/**
* Regions Controller
*
* @property \CakeAddresses\Model\Table\RegionsTable $Regions
*/
class RegionsController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|null|void Renders view
*/
public function index()
{
$query = $this->Regions->find();
$regions = $this->paginate($query);
$this->set(compact('regions'));
}
/**
* View method
*
* @param string|null $id Region id.
* @return \Cake\Http\Response|null|void Renders view
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$region = $this->Regions->get($id, contain: ['Countries', 'Subregions']);
$this->set(compact('region'));
}
}

View File

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Controller;
use CakeAddresses\Controller\AppController;
use Cake\Log\Log;
/**
* States Controller
*
* @property \CakeAddresses\Model\Table\StatesTable $States
*/
class StatesController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|null|void Renders view
*/
public function index()
{
$query = $this->States->find()
->contain(['Countries']);
$states = $this->paginate($query);
$this->set(compact('states'));
}
/**
* View method
*
* @param string|null $id State id.
* @return \Cake\Http\Response|null|void Renders view
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$state = $this->States->get($id, contain: ['Countries', 'Addresses', 'Cities']);
$this->set(compact('state'));
}
/**
* @return \Cake\Http\Response|null|void Renders view
*/
public function select()
{
$states = $this->States
->find('list')
->where(['country_id' => $this->request->getQuery('country_id', -1)])
->orderBy(['States.name'])
->toArray();
$this->set(compact('states'));
}
}

View File

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Controller;
use CakeAddresses\Controller\AppController;
/**
* Subregions Controller
*
* @property \CakeAddresses\Model\Table\SubregionsTable $Subregions
*/
class SubregionsController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|null|void Renders view
*/
public function index()
{
$query = $this->Subregions->find()
->contain(['Regions']);
$subregions = $this->paginate($query);
$this->set(compact('subregions'));
}
/**
* View method
*
* @param string|null $id Subregion id.
* @return \Cake\Http\Response|null|void Renders view
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$subregion = $this->Subregions->get($id, contain: ['Regions', 'Countries']);
$this->set(compact('subregion'));
}
}

View File

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Model\Entity;
use Cake\ORM\Entity;
/**
* Address Entity
*
* @property int $id
* @property string|null $address_name
* @property string|null $contact_name
* @property string $address_line1
* @property string|null $address_line2
* @property int|null $city_id
* @property int|null $state_id
* @property string $postal_code
* @property int|null $country_id
* @property string|null $phone_number
* @property string|null $email
* @property string|null $notes
*
* @property \CakeAddresses\Model\Entity\City $city
* @property \CakeAddresses\Model\Entity\State $state
* @property \CakeAddresses\Model\Entity\Country $country
*/
class Address extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array<string, bool>
*/
protected array $_accessible = [
'address_name' => true,
'contact_name' => true,
'address_line1' => true,
'address_line2' => true,
'city' => true,
'city_id' => true,
'state' => true,
'state_id' => true,
'postal_code' => true,
'country' => true,
'country_id' => true,
'phone_number' => true,
'email' => true,
'notes' => true,
];
}

55
src/Model/Entity/City.php Normal file
View File

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Model\Entity;
use Cake\ORM\Entity;
/**
* City Entity
*
* @property int $id
* @property string $name
* @property int $state_id
* @property string $state_code
* @property int $country_id
* @property string $country_code
* @property string $latitude
* @property string $longitude
* @property \Cake\I18n\DateTime $created_at
* @property \Cake\I18n\DateTime $updated_at
* @property bool $flag
* @property string|null $wikiDataId
*
* @property \CakeAddresses\Model\Entity\State $state
* @property \CakeAddresses\Model\Entity\Country $country
* @property \CakeAddresses\Model\Entity\Address[] $addresses
*/
class City extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array<string, bool>
*/
protected array $_accessible = [
'name' => true,
'state_id' => true,
'state_code' => true,
'country_id' => true,
'country_code' => true,
'latitude' => true,
'longitude' => true,
'created_at' => true,
'updated_at' => true,
'flag' => true,
'wikiDataId' => true,
'state' => true,
'country' => true,
'addresses' => true,
];
}

View File

@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Model\Entity;
use Cake\ORM\Entity;
/**
* Country Entity
*
* @property int $id
* @property string $name
* @property string|null $iso3
* @property string|null $numeric_code
* @property string|null $iso2
* @property string|null $phonecode
* @property string|null $capital
* @property string|null $currency
* @property string|null $currency_name
* @property string|null $currency_symbol
* @property string|null $tld
* @property string|null $native
* @property int|null $region_id
* @property int|null $subregion_id
* @property string|null $nationality
* @property string|null $timezones
* @property string|null $translations
* @property string|null $latitude
* @property string|null $longitude
* @property string|null $emoji
* @property string|null $emojiU
* @property \Cake\I18n\DateTime|null $created_at
* @property \Cake\I18n\DateTime $updated_at
* @property bool $flag
* @property string|null $wikiDataId
*
* @property \CakeAddresses\Model\Entity\Region $region
* @property \CakeAddresses\Model\Entity\Subregion $subregion
* @property \CakeAddresses\Model\Entity\Address[] $addresses
* @property \CakeAddresses\Model\Entity\City[] $cities
* @property \CakeAddresses\Model\Entity\State[] $states
*/
class Country extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array<string, bool>
*/
protected array $_accessible = [
'name' => true,
'iso3' => true,
'numeric_code' => true,
'iso2' => true,
'phonecode' => true,
'capital' => true,
'currency' => true,
'currency_name' => true,
'currency_symbol' => true,
'tld' => true,
'native' => true,
'region' => true,
'region_id' => true,
'subregion' => true,
'subregion_id' => true,
'nationality' => true,
'timezones' => true,
'translations' => true,
'latitude' => true,
'longitude' => true,
'emoji' => true,
'emojiU' => true,
'created_at' => true,
'updated_at' => true,
'flag' => true,
'wikiDataId' => true,
'addresses' => true,
'cities' => true,
'states' => true,
];
}

View File

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Model\Entity;
use Cake\ORM\Entity;
/**
* Region Entity
*
* @property int $id
* @property string $name
* @property string|null $translations
* @property \Cake\I18n\DateTime|null $created_at
* @property \Cake\I18n\DateTime $updated_at
* @property bool $flag
* @property string|null $wikiDataId
*
* @property \CakeAddresses\Model\Entity\Country[] $countries
* @property \CakeAddresses\Model\Entity\Subregion[] $subregions
*/
class Region extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array<string, bool>
*/
protected array $_accessible = [
'name' => true,
'translations' => true,
'created_at' => true,
'updated_at' => true,
'flag' => true,
'wikiDataId' => true,
'countries' => true,
'subregions' => true,
];
}

View File

@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Model\Entity;
use Cake\ORM\Entity;
/**
* State Entity
*
* @property int $id
* @property string $name
* @property int $country_id
* @property string $country_code
* @property string|null $fips_code
* @property string|null $iso2
* @property string|null $type
* @property string|null $latitude
* @property string|null $longitude
* @property \Cake\I18n\DateTime|null $created_at
* @property \Cake\I18n\DateTime $updated_at
* @property bool $flag
* @property string|null $wikiDataId
*
* @property \CakeAddresses\Model\Entity\Country $country
* @property \CakeAddresses\Model\Entity\Address[] $addresses
* @property \CakeAddresses\Model\Entity\City[] $cities
*/
class State extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array<string, bool>
*/
protected array $_accessible = [
'name' => true,
'country_id' => true,
'country_code' => true,
'fips_code' => true,
'iso2' => true,
'type' => true,
'latitude' => true,
'longitude' => true,
'created_at' => true,
'updated_at' => true,
'flag' => true,
'wikiDataId' => true,
'country' => true,
'addresses' => true,
'cities' => true,
];
}

View File

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Model\Entity;
use Cake\ORM\Entity;
/**
* Subregion Entity
*
* @property int $id
* @property string $name
* @property string|null $translations
* @property int $region_id
* @property \Cake\I18n\DateTime|null $created_at
* @property \Cake\I18n\DateTime $updated_at
* @property bool $flag
* @property string|null $wikiDataId
*
* @property \CakeAddresses\Model\Entity\Region $region
* @property \CakeAddresses\Model\Entity\Country[] $countries
*/
class Subregion extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array<string, bool>
*/
protected array $_accessible = [
'name' => true,
'translations' => true,
'region_id' => true,
'created_at' => true,
'updated_at' => true,
'flag' => true,
'wikiDataId' => true,
'region' => true,
'countries' => true,
];
}

View File

@ -0,0 +1,185 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Model\Table;
use ArrayObject;
use Cake\Datasource\EntityInterface;
use Cake\Event\EventInterface;
use Cake\Log\Log;
use Cake\ORM\Query\SelectQuery;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
use CakeAddresses\Model\Entity\State;
/**
* Addresses Model
*
* @property \CakeAddresses\Model\Table\CitiesTable&\Cake\ORM\Association\BelongsTo $Cities
* @property \CakeAddresses\Model\Table\StatesTable&\Cake\ORM\Association\BelongsTo $States
* @property \CakeAddresses\Model\Table\CountriesTable&\Cake\ORM\Association\BelongsTo $Countries
*
* @method \CakeAddresses\Model\Entity\Address newEmptyEntity()
* @method \CakeAddresses\Model\Entity\Address newEntity(array $data, array $options = [])
* @method array<\CakeAddresses\Model\Entity\Address> newEntities(array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\Address get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
* @method \CakeAddresses\Model\Entity\Address findOrCreate($search, ?callable $callback = null, array $options = [])
* @method \CakeAddresses\Model\Entity\Address patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method array<\CakeAddresses\Model\Entity\Address> patchEntities(iterable $entities, array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\Address|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method \CakeAddresses\Model\Entity\Address saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Address>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Address>|false saveMany(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Address>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Address> saveManyOrFail(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Address>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Address>|false deleteMany(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Address>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Address> deleteManyOrFail(iterable $entities, array $options = [])
*/
class AddressesTable extends Table
{
/**
* Initialize method
*
* @param array<string, mixed> $config The configuration for the Table.
* @return void
*/
public function initialize(array $config): void
{
parent::initialize($config);
$this->setTable('addresses');
$this->setDisplayField('address_line1');
$this->setPrimaryKey('id');
$this->belongsTo('Cities', [
'foreignKey' => 'city_id',
'className' => 'CakeAddresses.Cities',
'propertyName' => 'city_entity',
]);
$this->belongsTo('States', [
'foreignKey' => 'state_id',
'className' => 'CakeAddresses.States',
'propertyName' => 'state_entity',
]);
$this->belongsTo('Countries', [
'foreignKey' => 'country_id',
'className' => 'CakeAddresses.Countries',
'propertyName' => 'country_entity',
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator): Validator
{
$validator
->scalar('address_name')
->maxLength('address_name', 255)
->allowEmptyString('address_name');
$validator
->scalar('contact_name')
->maxLength('contact_name', 255)
->allowEmptyString('contact_name');
$validator
->scalar('address_line1')
->maxLength('address_line1', 255)
->requirePresence('address_line1', 'create')
->notEmptyString('address_line1');
$validator
->scalar('address_line2')
->maxLength('address_line2', 255)
->allowEmptyString('address_line2');
$validator
->scalar('city')
->maxLength('city', 255)
->requirePresence('city', 'create')
->notEmptyString('city');
$validator
->integer('city_id')
->allowEmptyString('city_id');
$validator
->scalar('state')
->maxLength('state', 255)
->requirePresence('state', 'create')
->notEmptyString('state');
$validator
->integer('state_id')
->allowEmptyString('state_id');
$validator
->scalar('postal_code')
->maxLength('postal_code', 25)
->requirePresence('postal_code', 'create')
->notEmptyString('postal_code');
$validator
->scalar('country')
->maxLength('country', 255)
->requirePresence('country', 'create')
->notEmptyString('country');
$validator
->integer('country_id')
->allowEmptyString('country_id');
$validator
->scalar('phone_number')
->maxLength('phone_number', 25)
->allowEmptyString('phone_number');
$validator
->email('email')
->allowEmptyString('email');
$validator
->scalar('notes')
->allowEmptyString('notes');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules): RulesChecker
{
$rules->add($rules->existsIn('city_id', 'Cities'), ['errorField' => 'city_id']);
$rules->add($rules->existsIn('state_id', 'States'), ['errorField' => 'state_id']);
$rules->add($rules->existsIn('country_id', 'Countries'), ['errorField' => 'country_id']);
return $rules;
}
/**
* @param EventInterface $event
* @param ArrayObject $data
* @param ArrayObject $options
*
* @return void
*/
public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options): void
{
if ($data['state_id'] && !isset($data['state'])) {
$state = $this->States->find()->where(['id' => $data['state_id']])->first();
$data['state'] = $state ? $state->name : null;
}
if ($data['country_id'] && !isset($data['country'])) {
$country = $this->Countries->find()->where(['id' => $data['country_id']])->first();
$data['country'] = $country ? $country->name : null;
}
}
}

View File

@ -0,0 +1,142 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Model\Table;
use Cake\ORM\Query\SelectQuery;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* Cities Model
*
* @property \CakeAddresses\Model\Table\StatesTable&\Cake\ORM\Association\BelongsTo $States
* @property \CakeAddresses\Model\Table\CountriesTable&\Cake\ORM\Association\BelongsTo $Countries
* @property \CakeAddresses\Model\Table\AddressesTable&\Cake\ORM\Association\HasMany $Addresses
*
* @method \CakeAddresses\Model\Entity\City newEmptyEntity()
* @method \CakeAddresses\Model\Entity\City newEntity(array $data, array $options = [])
* @method array<\CakeAddresses\Model\Entity\City> newEntities(array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\City get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
* @method \CakeAddresses\Model\Entity\City findOrCreate($search, ?callable $callback = null, array $options = [])
* @method \CakeAddresses\Model\Entity\City patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method array<\CakeAddresses\Model\Entity\City> patchEntities(iterable $entities, array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\City|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method \CakeAddresses\Model\Entity\City saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\City>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\City>|false saveMany(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\City>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\City> saveManyOrFail(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\City>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\City>|false deleteMany(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\City>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\City> deleteManyOrFail(iterable $entities, array $options = [])
*/
class CitiesTable extends Table
{
/**
* Initialize method
*
* @param array<string, mixed> $config The configuration for the Table.
* @return void
*/
public function initialize(array $config): void
{
parent::initialize($config);
$this->setTable('cities');
$this->setDisplayField('name');
$this->setPrimaryKey('id');
$this->belongsTo('States', [
'foreignKey' => 'state_id',
'joinType' => 'INNER',
'className' => 'CakeAddresses.States',
]);
$this->belongsTo('Countries', [
'foreignKey' => 'country_id',
'joinType' => 'INNER',
'className' => 'CakeAddresses.Countries',
]);
$this->hasMany('Addresses', [
'foreignKey' => 'city_id',
'className' => 'CakeAddresses.Addresses',
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator): Validator
{
$validator
->scalar('name')
->maxLength('name', 255)
->requirePresence('name', 'create')
->notEmptyString('name');
$validator
->nonNegativeInteger('state_id')
->notEmptyString('state_id');
$validator
->scalar('state_code')
->maxLength('state_code', 255)
->requirePresence('state_code', 'create')
->notEmptyString('state_code');
$validator
->nonNegativeInteger('country_id')
->notEmptyString('country_id');
$validator
->scalar('country_code')
->maxLength('country_code', 2)
->requirePresence('country_code', 'create')
->notEmptyString('country_code');
$validator
->decimal('latitude')
->requirePresence('latitude', 'create')
->notEmptyString('latitude');
$validator
->decimal('longitude')
->requirePresence('longitude', 'create')
->notEmptyString('longitude');
$validator
->dateTime('created_at')
->notEmptyDateTime('created_at');
$validator
->dateTime('updated_at')
->notEmptyDateTime('updated_at');
$validator
->boolean('flag')
->notEmptyString('flag');
$validator
->scalar('wikiDataId')
->maxLength('wikiDataId', 255)
->allowEmptyString('wikiDataId');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules): RulesChecker
{
$rules->add($rules->existsIn('state_id', 'States'), ['errorField' => 'state_id']);
$rules->add($rules->existsIn('country_id', 'Countries'), ['errorField' => 'country_id']);
return $rules;
}
}

View File

@ -0,0 +1,221 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Model\Table;
use Cake\ORM\Query\SelectQuery;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* Countries Model
*
* @property \CakeAddresses\Model\Table\RegionsTable&\Cake\ORM\Association\BelongsTo $Regions
* @property \CakeAddresses\Model\Table\SubregionsTable&\Cake\ORM\Association\BelongsTo $Subregions
* @property \CakeAddresses\Model\Table\AddressesTable&\Cake\ORM\Association\HasMany $Addresses
* @property \CakeAddresses\Model\Table\CitiesTable&\Cake\ORM\Association\HasMany $Cities
* @property \CakeAddresses\Model\Table\StatesTable&\Cake\ORM\Association\HasMany $States
*
* @method \CakeAddresses\Model\Entity\Country newEmptyEntity()
* @method \CakeAddresses\Model\Entity\Country newEntity(array $data, array $options = [])
* @method array<\CakeAddresses\Model\Entity\Country> newEntities(array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\Country get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
* @method \CakeAddresses\Model\Entity\Country findOrCreate($search, ?callable $callback = null, array $options = [])
* @method \CakeAddresses\Model\Entity\Country patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method array<\CakeAddresses\Model\Entity\Country> patchEntities(iterable $entities, array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\Country|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method \CakeAddresses\Model\Entity\Country saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Country>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Country>|false saveMany(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Country>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Country> saveManyOrFail(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Country>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Country>|false deleteMany(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Country>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Country> deleteManyOrFail(iterable $entities, array $options = [])
*/
class CountriesTable extends Table
{
/**
* Initialize method
*
* @param array<string, mixed> $config The configuration for the Table.
* @return void
*/
public function initialize(array $config): void
{
parent::initialize($config);
$this->setTable('countries');
$this->setDisplayField('name');
$this->setPrimaryKey('id');
$this->belongsTo('Regions', [
'foreignKey' => 'region_id',
'className' => 'CakeAddresses.Regions',
'propertyName' => 'region_entity',
]);
$this->belongsTo('Subregions', [
'foreignKey' => 'subregion_id',
'className' => 'CakeAddresses.Subregions',
'propertyName' => 'subregion_entity',
]);
$this->hasMany('Addresses', [
'foreignKey' => 'country_id',
'className' => 'CakeAddresses.Addresses',
]);
$this->hasMany('Cities', [
'foreignKey' => 'country_id',
'className' => 'CakeAddresses.Cities',
]);
$this->hasMany('States', [
'foreignKey' => 'country_id',
'className' => 'CakeAddresses.States',
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator): Validator
{
$validator
->scalar('name')
->maxLength('name', 100)
->requirePresence('name', 'create')
->notEmptyString('name');
$validator
->scalar('iso3')
->maxLength('iso3', 3)
->allowEmptyString('iso3');
$validator
->scalar('numeric_code')
->maxLength('numeric_code', 3)
->allowEmptyString('numeric_code');
$validator
->scalar('iso2')
->maxLength('iso2', 2)
->allowEmptyString('iso2');
$validator
->scalar('phonecode')
->maxLength('phonecode', 255)
->allowEmptyString('phonecode');
$validator
->scalar('capital')
->maxLength('capital', 255)
->allowEmptyString('capital');
$validator
->scalar('currency')
->maxLength('currency', 255)
->allowEmptyString('currency');
$validator
->scalar('currency_name')
->maxLength('currency_name', 255)
->allowEmptyString('currency_name');
$validator
->scalar('currency_symbol')
->maxLength('currency_symbol', 255)
->allowEmptyString('currency_symbol');
$validator
->scalar('tld')
->maxLength('tld', 255)
->allowEmptyString('tld');
$validator
->scalar('native')
->maxLength('native', 255)
->allowEmptyString('native');
$validator
->scalar('region')
->maxLength('region', 255)
->allowEmptyString('region');
$validator
->nonNegativeInteger('region_id')
->allowEmptyString('region_id');
$validator
->scalar('subregion')
->maxLength('subregion', 255)
->allowEmptyString('subregion');
$validator
->nonNegativeInteger('subregion_id')
->allowEmptyString('subregion_id');
$validator
->scalar('nationality')
->maxLength('nationality', 255)
->allowEmptyString('nationality');
$validator
->scalar('timezones')
->allowEmptyString('timezones');
$validator
->scalar('translations')
->allowEmptyString('translations');
$validator
->decimal('latitude')
->allowEmptyString('latitude');
$validator
->decimal('longitude')
->allowEmptyString('longitude');
$validator
->scalar('emoji')
->maxLength('emoji', 191)
->allowEmptyString('emoji');
$validator
->scalar('emojiU')
->maxLength('emojiU', 191)
->allowEmptyString('emojiU');
$validator
->dateTime('created_at')
->allowEmptyDateTime('created_at');
$validator
->dateTime('updated_at')
->notEmptyDateTime('updated_at');
$validator
->boolean('flag')
->notEmptyString('flag');
$validator
->scalar('wikiDataId')
->maxLength('wikiDataId', 255)
->allowEmptyString('wikiDataId');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules): RulesChecker
{
$rules->add($rules->existsIn('region_id', 'Regions'), ['errorField' => 'region_id']);
$rules->add($rules->existsIn('subregion_id', 'Subregions'), ['errorField' => 'subregion_id']);
return $rules;
}
}

View File

@ -0,0 +1,94 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Model\Table;
use Cake\ORM\Query\SelectQuery;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* Regions Model
*
* @property \CakeAddresses\Model\Table\CountriesTable&\Cake\ORM\Association\HasMany $Countries
* @property \CakeAddresses\Model\Table\SubregionsTable&\Cake\ORM\Association\HasMany $Subregions
*
* @method \CakeAddresses\Model\Entity\Region newEmptyEntity()
* @method \CakeAddresses\Model\Entity\Region newEntity(array $data, array $options = [])
* @method array<\CakeAddresses\Model\Entity\Region> newEntities(array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\Region get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
* @method \CakeAddresses\Model\Entity\Region findOrCreate($search, ?callable $callback = null, array $options = [])
* @method \CakeAddresses\Model\Entity\Region patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method array<\CakeAddresses\Model\Entity\Region> patchEntities(iterable $entities, array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\Region|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method \CakeAddresses\Model\Entity\Region saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Region>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Region>|false saveMany(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Region>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Region> saveManyOrFail(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Region>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Region>|false deleteMany(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Region>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Region> deleteManyOrFail(iterable $entities, array $options = [])
*/
class RegionsTable extends Table
{
/**
* Initialize method
*
* @param array<string, mixed> $config The configuration for the Table.
* @return void
*/
public function initialize(array $config): void
{
parent::initialize($config);
$this->setTable('regions');
$this->setDisplayField('name');
$this->setPrimaryKey('id');
$this->hasMany('Countries', [
'foreignKey' => 'region_id',
'className' => 'CakeAddresses.Countries',
]);
$this->hasMany('Subregions', [
'foreignKey' => 'region_id',
'className' => 'CakeAddresses.Subregions',
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator): Validator
{
$validator
->scalar('name')
->maxLength('name', 100)
->requirePresence('name', 'create')
->notEmptyString('name');
$validator
->scalar('translations')
->allowEmptyString('translations');
$validator
->dateTime('created_at')
->allowEmptyDateTime('created_at');
$validator
->dateTime('updated_at')
->notEmptyDateTime('updated_at');
$validator
->boolean('flag')
->notEmptyString('flag');
$validator
->scalar('wikiDataId')
->maxLength('wikiDataId', 255)
->allowEmptyString('wikiDataId');
return $validator;
}
}

View File

@ -0,0 +1,143 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Model\Table;
use Cake\ORM\Query\SelectQuery;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* States Model
*
* @property \CakeAddresses\Model\Table\CountriesTable&\Cake\ORM\Association\BelongsTo $Countries
* @property \CakeAddresses\Model\Table\AddressesTable&\Cake\ORM\Association\HasMany $Addresses
* @property \CakeAddresses\Model\Table\CitiesTable&\Cake\ORM\Association\HasMany $Cities
*
* @method \CakeAddresses\Model\Entity\State newEmptyEntity()
* @method \CakeAddresses\Model\Entity\State newEntity(array $data, array $options = [])
* @method array<\CakeAddresses\Model\Entity\State> newEntities(array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\State get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
* @method \CakeAddresses\Model\Entity\State findOrCreate($search, ?callable $callback = null, array $options = [])
* @method \CakeAddresses\Model\Entity\State patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method array<\CakeAddresses\Model\Entity\State> patchEntities(iterable $entities, array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\State|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method \CakeAddresses\Model\Entity\State saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\State>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\State>|false saveMany(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\State>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\State> saveManyOrFail(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\State>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\State>|false deleteMany(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\State>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\State> deleteManyOrFail(iterable $entities, array $options = [])
*/
class StatesTable extends Table
{
/**
* Initialize method
*
* @param array<string, mixed> $config The configuration for the Table.
* @return void
*/
public function initialize(array $config): void
{
parent::initialize($config);
$this->setTable('states');
$this->setDisplayField('name');
$this->setPrimaryKey('id');
$this->belongsTo('Countries', [
'foreignKey' => 'country_id',
'joinType' => 'INNER',
'className' => 'CakeAddresses.Countries',
]);
$this->hasMany('Addresses', [
'foreignKey' => 'state_id',
'className' => 'CakeAddresses.Addresses',
]);
$this->hasMany('Cities', [
'foreignKey' => 'state_id',
'className' => 'CakeAddresses.Cities',
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator): Validator
{
$validator
->scalar('name')
->maxLength('name', 255)
->requirePresence('name', 'create')
->notEmptyString('name');
$validator
->nonNegativeInteger('country_id')
->notEmptyString('country_id');
$validator
->scalar('country_code')
->maxLength('country_code', 2)
->requirePresence('country_code', 'create')
->notEmptyString('country_code');
$validator
->scalar('fips_code')
->maxLength('fips_code', 255)
->allowEmptyString('fips_code');
$validator
->scalar('iso2')
->maxLength('iso2', 255)
->allowEmptyString('iso2');
$validator
->scalar('type')
->maxLength('type', 191)
->allowEmptyString('type');
$validator
->decimal('latitude')
->allowEmptyString('latitude');
$validator
->decimal('longitude')
->allowEmptyString('longitude');
$validator
->dateTime('created_at')
->allowEmptyDateTime('created_at');
$validator
->dateTime('updated_at')
->notEmptyDateTime('updated_at');
$validator
->boolean('flag')
->notEmptyString('flag');
$validator
->scalar('wikiDataId')
->maxLength('wikiDataId', 255)
->allowEmptyString('wikiDataId');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules): RulesChecker
{
$rules->add($rules->existsIn('country_id', 'Countries'), ['errorField' => 'country_id']);
return $rules;
}
}

View File

@ -0,0 +1,113 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Model\Table;
use Cake\ORM\Query\SelectQuery;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* Subregions Model
*
* @property \CakeAddresses\Model\Table\RegionsTable&\Cake\ORM\Association\BelongsTo $Regions
* @property \CakeAddresses\Model\Table\CountriesTable&\Cake\ORM\Association\HasMany $Countries
*
* @method \CakeAddresses\Model\Entity\Subregion newEmptyEntity()
* @method \CakeAddresses\Model\Entity\Subregion newEntity(array $data, array $options = [])
* @method array<\CakeAddresses\Model\Entity\Subregion> newEntities(array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\Subregion get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
* @method \CakeAddresses\Model\Entity\Subregion findOrCreate($search, ?callable $callback = null, array $options = [])
* @method \CakeAddresses\Model\Entity\Subregion patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method array<\CakeAddresses\Model\Entity\Subregion> patchEntities(iterable $entities, array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\Subregion|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method \CakeAddresses\Model\Entity\Subregion saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Subregion>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Subregion>|false saveMany(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Subregion>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Subregion> saveManyOrFail(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Subregion>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Subregion>|false deleteMany(iterable $entities, array $options = [])
* @method iterable<\CakeAddresses\Model\Entity\Subregion>|\Cake\Datasource\ResultSetInterface<\CakeAddresses\Model\Entity\Subregion> deleteManyOrFail(iterable $entities, array $options = [])
*/
class SubregionsTable extends Table
{
/**
* Initialize method
*
* @param array<string, mixed> $config The configuration for the Table.
* @return void
*/
public function initialize(array $config): void
{
parent::initialize($config);
$this->setTable('subregions');
$this->setDisplayField('name');
$this->setPrimaryKey('id');
$this->belongsTo('Regions', [
'foreignKey' => 'region_id',
'joinType' => 'INNER',
'className' => 'CakeAddresses.Regions',
]);
$this->hasMany('Countries', [
'foreignKey' => 'subregion_id',
'className' => 'CakeAddresses.Countries',
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator): Validator
{
$validator
->scalar('name')
->maxLength('name', 100)
->requirePresence('name', 'create')
->notEmptyString('name');
$validator
->scalar('translations')
->allowEmptyString('translations');
$validator
->nonNegativeInteger('region_id')
->notEmptyString('region_id');
$validator
->dateTime('created_at')
->allowEmptyDateTime('created_at');
$validator
->dateTime('updated_at')
->notEmptyDateTime('updated_at');
$validator
->boolean('flag')
->notEmptyString('flag');
$validator
->scalar('wikiDataId')
->maxLength('wikiDataId', 255)
->allowEmptyString('wikiDataId');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules): RulesChecker
{
$rules->add($rules->existsIn('region_id', 'Regions'), ['errorField' => 'region_id']);
return $rules;
}
}

View File

@ -0,0 +1,28 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $address
* @var \Cake\Collection\CollectionInterface|string[] $cities
* @var \Cake\Collection\CollectionInterface|string[] $states
* @var \Cake\Collection\CollectionInterface|string[] $countries
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('List Addresses'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="addresses form content">
<?= $this->Form->create($address) ?>
<fieldset>
<legend><?= __('Add Address') ?></legend>
<?= $this->element('Addresses/form'); ?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>

View File

@ -0,0 +1,47 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $address
* @var string[]|\Cake\Collection\CollectionInterface $cities
* @var string[]|\Cake\Collection\CollectionInterface $states
* @var string[]|\Cake\Collection\CollectionInterface $countries
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Form->postLink(
__('Delete'),
[
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'delete',
$address->id,
],
[
'confirm' => __('Are you sure you want to delete # {0}?', $address->id),
'class' => 'side-nav-item',
]
) ?>
<?= $this->Html->link(__('List Addresses'), [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'index',
], [
'class' => 'side-nav-item',
]) ?>
</div>
</aside>
<div class="column column-80">
<div class="addresses form content">
<?= $this->Form->create($address) ?>
<fieldset>
<legend><?= __('Edit Address') ?></legend>
<?= $this->element('Addresses/form'); ?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>

View File

@ -0,0 +1,89 @@
<?php
/**
* @var \App\View\AppView $this
* @var iterable<\Cake\Datasource\EntityInterface|\CakeAddresses\Model\Entity\Address> $addresses
*/
?>
<div class="addresses index content">
<?= $this->Html->link(__('New Address'), [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'add'
], [
'class' => 'button float-right'
]) ?>
<h3><?= __('Addresses') ?></h3>
<div class="table-responsive">
<table>
<thead>
<tr>
<th><?= $this->Paginator->sort('id') ?></th>
<th><?= $this->Paginator->sort('address_name') ?></th>
<th><?= $this->Paginator->sort('contact_name') ?></th>
<th><?= $this->Paginator->sort('address_line1') ?></th>
<th><?= $this->Paginator->sort('address_line2') ?></th>
<th><?= $this->Paginator->sort('city') ?></th>
<th><?= $this->Paginator->sort('city_id') ?></th>
<th><?= $this->Paginator->sort('state') ?></th>
<th><?= $this->Paginator->sort('state_id') ?></th>
<th><?= $this->Paginator->sort('postal_code') ?></th>
<th><?= $this->Paginator->sort('country') ?></th>
<th><?= $this->Paginator->sort('country_id') ?></th>
<th><?= $this->Paginator->sort('phone_number') ?></th>
<th><?= $this->Paginator->sort('email') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($addresses as $address): ?>
<tr>
<td><?= $this->Number->format($address->id) ?></td>
<td><?= h($address->address_name) ?></td>
<td><?= h($address->contact_name) ?></td>
<td><?= h($address->address_line1) ?></td>
<td><?= h($address->address_line2) ?></td>
<td><?= h($address->city) ?></td>
<td><?= $address->hasValue('city_entity') ? $this->Html->link($address->city_entity->name, ['controller' => 'Cities', 'action' => 'view', $address->city_entity->id]) : '' ?></td>
<td><?= h($address->state) ?></td>
<td><?= $address->hasValue('state_entity') ? $this->Html->link($address->state_entity->name, ['controller' => 'States', 'action' => 'view', $address->state_entity->id]) : '' ?></td>
<td><?= h($address->postal_code) ?></td>
<td><?= h($address->country) ?></td>
<td><?= $address->hasValue('country_entity') ? $this->Html->link($address->country_entity->name, ['controller' => 'Countries', 'action' => 'view', $address->country_entity->id]) : '' ?></td>
<td><?= h($address->phone_number) ?></td>
<td><?= h($address->email) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'view',
$address->id,
]); ?>
<?= $this->Html->link(__('Edit'), [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'edit',
$address->id,
]) ?>
<?= $this->Form->postLink(__('Delete'), [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'delete',
$address->id,
], ['confirm' => __('Are you sure you want to delete # {0}?', $address->id)]) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->first('<< ' . __('first')) ?>
<?= $this->Paginator->prev('< ' . __('previous')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next(__('next') . ' >') ?>
<?= $this->Paginator->last(__('last') . ' >>') ?>
</ul>
<p><?= $this->Paginator->counter(__('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')) ?></p>
</div>
</div>

View File

@ -0,0 +1,86 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $address
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('Edit Address'), ['action' => 'edit', $address->id], ['class' => 'side-nav-item']) ?>
<?= $this->Form->postLink(__('Delete Address'), ['action' => 'delete', $address->id], ['confirm' => __('Are you sure you want to delete # {0}?', $address->id), 'class' => 'side-nav-item']) ?>
<?= $this->Html->link(__('List Addresses'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
<?= $this->Html->link(__('New Address'), ['action' => 'add'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="addresses view content">
<h3><?= h($address->address_line1) ?></h3>
<table>
<tr>
<th><?= __('Address Name') ?></th>
<td><?= h($address->address_name) ?></td>
</tr>
<tr>
<th><?= __('Contact Name') ?></th>
<td><?= h($address->contact_name) ?></td>
</tr>
<tr>
<th><?= __('Address Line1') ?></th>
<td><?= h($address->address_line1) ?></td>
</tr>
<tr>
<th><?= __('Address Line2') ?></th>
<td><?= h($address->address_line2) ?></td>
</tr>
<tr>
<th><?= __('City') ?></th>
<td><?= h($address->city) ?></td>
</tr>
<tr>
<th><?= __('City') ?></th>
<td><?= $address->hasValue('city_entity') ? $this->Html->link($address->city_entity->name, ['controller' => 'Cities', 'action' => 'view', $address->city_entity->id]) : '' ?></td>
</tr>
<tr>
<th><?= __('State') ?></th>
<td><?= h($address->state) ?></td>
</tr>
<tr>
<th><?= __('State') ?></th>
<td><?= $address->hasValue('state_entity') ? $this->Html->link($address->state_entity->name, ['controller' => 'States', 'action' => 'view', $address->state_entity->id]) : '' ?></td>
</tr>
<tr>
<th><?= __('Postal Code') ?></th>
<td><?= h($address->postal_code) ?></td>
</tr>
<tr>
<th><?= __('Country') ?></th>
<td><?= h($address->country) ?></td>
</tr>
<tr>
<th><?= __('Country') ?></th>
<td><?= $address->hasValue('country_entity') ? $this->Html->link($address->country_entity->name, ['controller' => 'Countries', 'action' => 'view', $address->country_entity->id]) : '' ?></td>
</tr>
<tr>
<th><?= __('Phone Number') ?></th>
<td><?= h($address->phone_number) ?></td>
</tr>
<tr>
<th><?= __('Email') ?></th>
<td><?= h($address->email) ?></td>
</tr>
<tr>
<th><?= __('Id') ?></th>
<td><?= $this->Number->format($address->id) ?></td>
</tr>
</table>
<div class="text">
<strong><?= __('Notes') ?></strong>
<blockquote>
<?= $this->Text->autoParagraph(h($address->notes)); ?>
</blockquote>
</div>
</div>
</div>
</div>

39
templates/Cities/add.php Normal file
View File

@ -0,0 +1,39 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $city
* @var \Cake\Collection\CollectionInterface|string[] $states
* @var \Cake\Collection\CollectionInterface|string[] $countries
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('List Cities'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="cities form content">
<?= $this->Form->create($city) ?>
<fieldset>
<legend><?= __('Add City') ?></legend>
<?php
echo $this->Form->control('name');
echo $this->Form->control('state_id', ['options' => $states]);
echo $this->Form->control('state_code');
echo $this->Form->control('country_id', ['options' => $countries]);
echo $this->Form->control('country_code');
echo $this->Form->control('latitude');
echo $this->Form->control('longitude');
echo $this->Form->control('created_at');
echo $this->Form->control('updated_at');
echo $this->Form->control('flag');
echo $this->Form->control('wikiDataId');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>

44
templates/Cities/edit.php Normal file
View File

@ -0,0 +1,44 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $city
* @var string[]|\Cake\Collection\CollectionInterface $states
* @var string[]|\Cake\Collection\CollectionInterface $countries
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $city->id],
['confirm' => __('Are you sure you want to delete # {0}?', $city->id), 'class' => 'side-nav-item']
) ?>
<?= $this->Html->link(__('List Cities'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="cities form content">
<?= $this->Form->create($city) ?>
<fieldset>
<legend><?= __('Edit City') ?></legend>
<?php
echo $this->Form->control('name');
echo $this->Form->control('state_id', ['options' => $states]);
echo $this->Form->control('state_code');
echo $this->Form->control('country_id', ['options' => $countries]);
echo $this->Form->control('country_code');
echo $this->Form->control('latitude');
echo $this->Form->control('longitude');
echo $this->Form->control('created_at');
echo $this->Form->control('updated_at');
echo $this->Form->control('flag');
echo $this->Form->control('wikiDataId');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>

View File

@ -0,0 +1,61 @@
<?php
/**
* @var \App\View\AppView $this
* @var iterable<\Cake\Datasource\EntityInterface> $cities
*/
?>
<div class="cities index content">
<h3><?= __('Cities') ?></h3>
<div class="table-responsive">
<table>
<thead>
<tr>
<th><?= $this->Paginator->sort('id') ?></th>
<th><?= $this->Paginator->sort('name') ?></th>
<th><?= $this->Paginator->sort('state_id') ?></th>
<th><?= $this->Paginator->sort('state_code') ?></th>
<th><?= $this->Paginator->sort('country_id') ?></th>
<th><?= $this->Paginator->sort('country_code') ?></th>
<th><?= $this->Paginator->sort('latitude') ?></th>
<th><?= $this->Paginator->sort('longitude') ?></th>
<th><?= $this->Paginator->sort('created_at') ?></th>
<th><?= $this->Paginator->sort('updated_at') ?></th>
<th><?= $this->Paginator->sort('flag') ?></th>
<th><?= $this->Paginator->sort('wikiDataId') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($cities as $city): ?>
<tr>
<td><?= $this->Number->format($city->id) ?></td>
<td><?= h($city->name) ?></td>
<td><?= $city->hasValue('state') ? $this->Html->link($city->state->name, ['controller' => 'States', 'action' => 'view', $city->state->id]) : '' ?></td>
<td><?= h($city->state_code) ?></td>
<td><?= $city->hasValue('country') ? $this->Html->link($city->country->name, ['controller' => 'Countries', 'action' => 'view', $city->country->id]) : '' ?></td>
<td><?= h($city->country_code) ?></td>
<td><?= $this->Number->format($city->latitude) ?></td>
<td><?= $this->Number->format($city->longitude) ?></td>
<td><?= h($city->created_at) ?></td>
<td><?= h($city->updated_at) ?></td>
<td><?= h($city->flag) ?></td>
<td><?= h($city->wikiDataId) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $city->id]) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->first('<< ' . __('first')) ?>
<?= $this->Paginator->prev('< ' . __('previous')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next(__('next') . ' >') ?>
<?= $this->Paginator->last(__('last') . ' >>') ?>
</ul>
<p><?= $this->Paginator->counter(__('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')) ?></p>
</div>
</div>

View File

@ -0,0 +1,10 @@
<?php
/**
* @var \App\View\AppView $this
* @var iterable<\Cake\Datasource\EntityInterface> $cities
*/
$this->setLayout('ajax');
?>
<?php foreach ($cities as $cityId => $city): ?>
<option value="<?= $cityId; ?>"><?= $city; ?></option>
<?php endforeach; ?>

120
templates/Cities/view.php Normal file
View File

@ -0,0 +1,120 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $city
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('List Cities'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="cities view content">
<h3><?= h($city->name) ?></h3>
<table>
<tr>
<th><?= __('Name') ?></th>
<td><?= h($city->name) ?></td>
</tr>
<tr>
<th><?= __('State') ?></th>
<td><?= $city->hasValue('state') ? $this->Html->link($city->state->name, ['controller' => 'States', 'action' => 'view', $city->state->id]) : '' ?></td>
</tr>
<tr>
<th><?= __('State Code') ?></th>
<td><?= h($city->state_code) ?></td>
</tr>
<tr>
<th><?= __('Country') ?></th>
<td><?= $city->hasValue('country') ? $this->Html->link($city->country->name, ['controller' => 'Countries', 'action' => 'view', $city->country->id]) : '' ?></td>
</tr>
<tr>
<th><?= __('Country Code') ?></th>
<td><?= h($city->country_code) ?></td>
</tr>
<tr>
<th><?= __('WikiDataId') ?></th>
<td><?= h($city->wikiDataId) ?></td>
</tr>
<tr>
<th><?= __('Id') ?></th>
<td><?= $this->Number->format($city->id) ?></td>
</tr>
<tr>
<th><?= __('Latitude') ?></th>
<td><?= $this->Number->format($city->latitude) ?></td>
</tr>
<tr>
<th><?= __('Longitude') ?></th>
<td><?= $this->Number->format($city->longitude) ?></td>
</tr>
<tr>
<th><?= __('Created At') ?></th>
<td><?= h($city->created_at) ?></td>
</tr>
<tr>
<th><?= __('Updated At') ?></th>
<td><?= h($city->updated_at) ?></td>
</tr>
<tr>
<th><?= __('Flag') ?></th>
<td><?= $city->flag ? __('Yes') : __('No'); ?></td>
</tr>
</table>
<div class="related">
<h4><?= __('Related Addresses') ?></h4>
<?php if (!empty($city->addresses)) : ?>
<div class="table-responsive">
<table>
<tr>
<th><?= __('Id') ?></th>
<th><?= __('Address Name') ?></th>
<th><?= __('Contact Name') ?></th>
<th><?= __('Address Line1') ?></th>
<th><?= __('Address Line2') ?></th>
<th><?= __('City') ?></th>
<th><?= __('City Id') ?></th>
<th><?= __('State') ?></th>
<th><?= __('State Id') ?></th>
<th><?= __('Postal Code') ?></th>
<th><?= __('Country') ?></th>
<th><?= __('Country Id') ?></th>
<th><?= __('Phone Number') ?></th>
<th><?= __('Email') ?></th>
<th><?= __('Notes') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
<?php foreach ($city->addresses as $addresses) : ?>
<tr>
<td><?= h($addresses->id) ?></td>
<td><?= h($addresses->address_name) ?></td>
<td><?= h($addresses->contact_name) ?></td>
<td><?= h($addresses->address_line1) ?></td>
<td><?= h($addresses->address_line2) ?></td>
<td><?= h($addresses->city) ?></td>
<td><?= h($addresses->city_id) ?></td>
<td><?= h($addresses->state) ?></td>
<td><?= h($addresses->state_id) ?></td>
<td><?= h($addresses->postal_code) ?></td>
<td><?= h($addresses->country) ?></td>
<td><?= h($addresses->country_id) ?></td>
<td><?= h($addresses->phone_number) ?></td>
<td><?= h($addresses->email) ?></td>
<td><?= h($addresses->notes) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => 'Addresses', 'action' => 'view', $addresses->id]) ?>
<?= $this->Html->link(__('Edit'), ['controller' => 'Addresses', 'action' => 'edit', $addresses->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['controller' => 'Addresses', 'action' => 'delete', $addresses->id], ['confirm' => __('Are you sure you want to delete # {0}?', $addresses->id)]) ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,54 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $country
* @var \Cake\Collection\CollectionInterface|string[] $regions
* @var \Cake\Collection\CollectionInterface|string[] $subregions
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('List Countries'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="countries form content">
<?= $this->Form->create($country) ?>
<fieldset>
<legend><?= __('Add Country') ?></legend>
<?php
echo $this->Form->control('name');
echo $this->Form->control('iso3');
echo $this->Form->control('numeric_code');
echo $this->Form->control('iso2');
echo $this->Form->control('phonecode');
echo $this->Form->control('capital');
echo $this->Form->control('currency');
echo $this->Form->control('currency_name');
echo $this->Form->control('currency_symbol');
echo $this->Form->control('tld');
echo $this->Form->control('native');
echo $this->Form->control('region');
echo $this->Form->control('region_id', ['options' => $regions, 'empty' => true]);
echo $this->Form->control('subregion');
echo $this->Form->control('subregion_id', ['options' => $subregions, 'empty' => true]);
echo $this->Form->control('nationality');
echo $this->Form->control('timezones');
echo $this->Form->control('translations');
echo $this->Form->control('latitude');
echo $this->Form->control('longitude');
echo $this->Form->control('emoji');
echo $this->Form->control('emojiU');
echo $this->Form->control('created_at');
echo $this->Form->control('updated_at');
echo $this->Form->control('flag');
echo $this->Form->control('wikiDataId');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>

View File

@ -0,0 +1,59 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $country
* @var string[]|\Cake\Collection\CollectionInterface $regions
* @var string[]|\Cake\Collection\CollectionInterface $subregions
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $country->id],
['confirm' => __('Are you sure you want to delete # {0}?', $country->id), 'class' => 'side-nav-item']
) ?>
<?= $this->Html->link(__('List Countries'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="countries form content">
<?= $this->Form->create($country) ?>
<fieldset>
<legend><?= __('Edit Country') ?></legend>
<?php
echo $this->Form->control('name');
echo $this->Form->control('iso3');
echo $this->Form->control('numeric_code');
echo $this->Form->control('iso2');
echo $this->Form->control('phonecode');
echo $this->Form->control('capital');
echo $this->Form->control('currency');
echo $this->Form->control('currency_name');
echo $this->Form->control('currency_symbol');
echo $this->Form->control('tld');
echo $this->Form->control('native');
echo $this->Form->control('region');
echo $this->Form->control('region_id', ['options' => $regions, 'empty' => true]);
echo $this->Form->control('subregion');
echo $this->Form->control('subregion_id', ['options' => $subregions, 'empty' => true]);
echo $this->Form->control('nationality');
echo $this->Form->control('timezones');
echo $this->Form->control('translations');
echo $this->Form->control('latitude');
echo $this->Form->control('longitude');
echo $this->Form->control('emoji');
echo $this->Form->control('emojiU');
echo $this->Form->control('created_at');
echo $this->Form->control('updated_at');
echo $this->Form->control('flag');
echo $this->Form->control('wikiDataId');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>

View File

@ -0,0 +1,90 @@
<?php
/**
* @var \App\View\AppView $this
* @var iterable<\Cake\Datasource\EntityInterface> $countries
*/
?>
<div class="countries index content">
<?= $this->Html->link(__('New Country'), ['action' => 'add'], ['class' => 'button float-right']) ?>
<h3><?= __('Countries') ?></h3>
<div class="table-responsive">
<table>
<thead>
<tr>
<th><?= $this->Paginator->sort('id') ?></th>
<th><?= $this->Paginator->sort('name') ?></th>
<th><?= $this->Paginator->sort('iso3') ?></th>
<th><?= $this->Paginator->sort('numeric_code') ?></th>
<th><?= $this->Paginator->sort('iso2') ?></th>
<th><?= $this->Paginator->sort('phonecode') ?></th>
<th><?= $this->Paginator->sort('capital') ?></th>
<th><?= $this->Paginator->sort('currency') ?></th>
<th><?= $this->Paginator->sort('currency_name') ?></th>
<th><?= $this->Paginator->sort('currency_symbol') ?></th>
<th><?= $this->Paginator->sort('tld') ?></th>
<th><?= $this->Paginator->sort('native') ?></th>
<th><?= $this->Paginator->sort('region') ?></th>
<th><?= $this->Paginator->sort('region_id') ?></th>
<th><?= $this->Paginator->sort('subregion') ?></th>
<th><?= $this->Paginator->sort('subregion_id') ?></th>
<th><?= $this->Paginator->sort('nationality') ?></th>
<th><?= $this->Paginator->sort('latitude') ?></th>
<th><?= $this->Paginator->sort('longitude') ?></th>
<th><?= $this->Paginator->sort('emoji') ?></th>
<th><?= $this->Paginator->sort('emojiU') ?></th>
<th><?= $this->Paginator->sort('created_at') ?></th>
<th><?= $this->Paginator->sort('updated_at') ?></th>
<th><?= $this->Paginator->sort('flag') ?></th>
<th><?= $this->Paginator->sort('wikiDataId') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($countries as $country): ?>
<tr>
<td><?= $this->Number->format($country->id) ?></td>
<td><?= h($country->name) ?></td>
<td><?= h($country->iso3) ?></td>
<td><?= h($country->numeric_code) ?></td>
<td><?= h($country->iso2) ?></td>
<td><?= h($country->phonecode) ?></td>
<td><?= h($country->capital) ?></td>
<td><?= h($country->currency) ?></td>
<td><?= h($country->currency_name) ?></td>
<td><?= h($country->currency_symbol) ?></td>
<td><?= h($country->tld) ?></td>
<td><?= h($country->native) ?></td>
<td><?= h($country->region) ?></td>
<td><?= $country->hasValue('region_entity') ? $this->Html->link($country->region_entity->name, ['controller' => 'Regions', 'action' => 'view', $country->region_entity->id]) : '' ?></td>
<td><?= h($country->subregion) ?></td>
<td><?= $country->hasValue('subregion_entity') ? $this->Html->link($country->subregion_entity->name, ['controller' => 'Subregions', 'action' => 'view', $country->subregion_entity->id]) : '' ?></td>
<td><?= h($country->nationality) ?></td>
<td><?= $country->latitude === null ? '' : $this->Number->format($country->latitude) ?></td>
<td><?= $country->longitude === null ? '' : $this->Number->format($country->longitude) ?></td>
<td><?= h($country->emoji) ?></td>
<td><?= h($country->emojiU) ?></td>
<td><?= h($country->created_at) ?></td>
<td><?= h($country->updated_at) ?></td>
<td><?= h($country->flag) ?></td>
<td><?= h($country->wikiDataId) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $country->id]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $country->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $country->id], ['confirm' => __('Are you sure you want to delete # {0}?', $country->id)]) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->first('<< ' . __('first')) ?>
<?= $this->Paginator->prev('< ' . __('previous')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next(__('next') . ' >') ?>
<?= $this->Paginator->last(__('last') . ' >>') ?>
</ul>
<p><?= $this->Paginator->counter(__('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')) ?></p>
</div>
</div>

View File

@ -0,0 +1,229 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $country
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('List Countries'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="countries view content">
<h3><?= h($country->name) ?></h3>
<table>
<tr>
<th><?= __('Name') ?></th>
<td><?= h($country->name) ?></td>
</tr>
<tr>
<th><?= __('Iso3') ?></th>
<td><?= h($country->iso3) ?></td>
</tr>
<tr>
<th><?= __('Numeric Code') ?></th>
<td><?= h($country->numeric_code) ?></td>
</tr>
<tr>
<th><?= __('Iso2') ?></th>
<td><?= h($country->iso2) ?></td>
</tr>
<tr>
<th><?= __('Phonecode') ?></th>
<td><?= h($country->phonecode) ?></td>
</tr>
<tr>
<th><?= __('Capital') ?></th>
<td><?= h($country->capital) ?></td>
</tr>
<tr>
<th><?= __('Currency') ?></th>
<td><?= h($country->currency) ?></td>
</tr>
<tr>
<th><?= __('Currency Name') ?></th>
<td><?= h($country->currency_name) ?></td>
</tr>
<tr>
<th><?= __('Currency Symbol') ?></th>
<td><?= h($country->currency_symbol) ?></td>
</tr>
<tr>
<th><?= __('Tld') ?></th>
<td><?= h($country->tld) ?></td>
</tr>
<tr>
<th><?= __('Native') ?></th>
<td><?= h($country->native) ?></td>
</tr>
<tr>
<th><?= __('Region') ?></th>
<td><?= h($country->region) ?></td>
</tr>
<tr>
<th><?= __('Region') ?></th>
<td><?= $country->hasValue('region_entity') ? $this->Html->link($country->region_entity->name, ['controller' => 'Regions', 'action' => 'view', $country->region_entity->id]) : '' ?></td>
</tr>
<tr>
<th><?= __('Subregion') ?></th>
<td><?= h($country->subregion) ?></td>
</tr>
<tr>
<th><?= __('Subregion') ?></th>
<td><?= $country->hasValue('subregion_entity') ? $this->Html->link($country->subregion_entity->name, ['controller' => 'Subregions', 'action' => 'view', $country->subregion_entity->id]) : '' ?></td>
</tr>
<tr>
<th><?= __('Nationality') ?></th>
<td><?= h($country->nationality) ?></td>
</tr>
<tr>
<th><?= __('Emoji') ?></th>
<td><?= h($country->emoji) ?></td>
</tr>
<tr>
<th><?= __('EmojiU') ?></th>
<td><?= h($country->emojiU) ?></td>
</tr>
<tr>
<th><?= __('WikiDataId') ?></th>
<td><?= h($country->wikiDataId) ?></td>
</tr>
<tr>
<th><?= __('Id') ?></th>
<td><?= $this->Number->format($country->id) ?></td>
</tr>
<tr>
<th><?= __('Latitude') ?></th>
<td><?= $country->latitude === null ? '' : $this->Number->format($country->latitude) ?></td>
</tr>
<tr>
<th><?= __('Longitude') ?></th>
<td><?= $country->longitude === null ? '' : $this->Number->format($country->longitude) ?></td>
</tr>
<tr>
<th><?= __('Created At') ?></th>
<td><?= h($country->created_at) ?></td>
</tr>
<tr>
<th><?= __('Updated At') ?></th>
<td><?= h($country->updated_at) ?></td>
</tr>
<tr>
<th><?= __('Flag') ?></th>
<td><?= $country->flag ? __('Yes') : __('No'); ?></td>
</tr>
</table>
<div class="text">
<strong><?= __('Timezones') ?></strong>
<blockquote>
<?= $this->Text->autoParagraph(h($country->timezones)); ?>
</blockquote>
</div>
<div class="text">
<strong><?= __('Translations') ?></strong>
<blockquote>
<?= $this->Text->autoParagraph(h($country->translations)); ?>
</blockquote>
</div>
<div class="related">
<h4><?= __('Related Addresses') ?></h4>
<?php if (!empty($country->addresses)) : ?>
<div class="table-responsive">
<table>
<tr>
<th><?= __('Id') ?></th>
<th><?= __('Address Name') ?></th>
<th><?= __('Contact Name') ?></th>
<th><?= __('Address Line1') ?></th>
<th><?= __('Address Line2') ?></th>
<th><?= __('City') ?></th>
<th><?= __('City Id') ?></th>
<th><?= __('State') ?></th>
<th><?= __('State Id') ?></th>
<th><?= __('Postal Code') ?></th>
<th><?= __('Country') ?></th>
<th><?= __('Country Id') ?></th>
<th><?= __('Phone Number') ?></th>
<th><?= __('Email') ?></th>
<th><?= __('Notes') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
<?php foreach ($country->addresses as $addresses) : ?>
<tr>
<td><?= h($addresses->id) ?></td>
<td><?= h($addresses->address_name) ?></td>
<td><?= h($addresses->contact_name) ?></td>
<td><?= h($addresses->address_line1) ?></td>
<td><?= h($addresses->address_line2) ?></td>
<td><?= h($addresses->city) ?></td>
<td><?= h($addresses->city_id) ?></td>
<td><?= h($addresses->state) ?></td>
<td><?= h($addresses->state_id) ?></td>
<td><?= h($addresses->postal_code) ?></td>
<td><?= h($addresses->country) ?></td>
<td><?= h($addresses->country_id) ?></td>
<td><?= h($addresses->phone_number) ?></td>
<td><?= h($addresses->email) ?></td>
<td><?= h($addresses->notes) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => 'Addresses', 'action' => 'view', $addresses->id]) ?>
<?= $this->Html->link(__('Edit'), ['controller' => 'Addresses', 'action' => 'edit', $addresses->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['controller' => 'Addresses', 'action' => 'delete', $addresses->id], ['confirm' => __('Are you sure you want to delete # {0}?', $addresses->id)]) ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<?php endif; ?>
</div>
<div class="related">
<h4><?= __('Related States') ?></h4>
<?php if (!empty($country->states)) : ?>
<div class="table-responsive">
<table>
<tr>
<th><?= __('Id') ?></th>
<th><?= __('Name') ?></th>
<th><?= __('Country Id') ?></th>
<th><?= __('Country Code') ?></th>
<th><?= __('Fips Code') ?></th>
<th><?= __('Iso2') ?></th>
<th><?= __('Type') ?></th>
<th><?= __('Latitude') ?></th>
<th><?= __('Longitude') ?></th>
<th><?= __('Created At') ?></th>
<th><?= __('Updated At') ?></th>
<th><?= __('Flag') ?></th>
<th><?= __('WikiDataId') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
<?php foreach ($country->states as $states) : ?>
<tr>
<td><?= h($states->id) ?></td>
<td><?= h($states->name) ?></td>
<td><?= h($states->country_id) ?></td>
<td><?= h($states->country_code) ?></td>
<td><?= h($states->fips_code) ?></td>
<td><?= h($states->iso2) ?></td>
<td><?= h($states->type) ?></td>
<td><?= h($states->latitude) ?></td>
<td><?= h($states->longitude) ?></td>
<td><?= h($states->created_at) ?></td>
<td><?= h($states->updated_at) ?></td>
<td><?= h($states->flag) ?></td>
<td><?= h($states->wikiDataId) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => 'States', 'action' => 'view', $states->id]) ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>

32
templates/Regions/add.php Normal file
View File

@ -0,0 +1,32 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $region
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('List Regions'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="regions form content">
<?= $this->Form->create($region) ?>
<fieldset>
<legend><?= __('Add Region') ?></legend>
<?php
echo $this->Form->control('name');
echo $this->Form->control('translations');
echo $this->Form->control('created_at');
echo $this->Form->control('updated_at');
echo $this->Form->control('flag');
echo $this->Form->control('wikiDataId');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>

View File

@ -0,0 +1,37 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $region
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $region->id],
['confirm' => __('Are you sure you want to delete # {0}?', $region->id), 'class' => 'side-nav-item']
) ?>
<?= $this->Html->link(__('List Regions'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="regions form content">
<?= $this->Form->create($region) ?>
<fieldset>
<legend><?= __('Edit Region') ?></legend>
<?php
echo $this->Form->control('name');
echo $this->Form->control('translations');
echo $this->Form->control('created_at');
echo $this->Form->control('updated_at');
echo $this->Form->control('flag');
echo $this->Form->control('wikiDataId');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>

View File

@ -0,0 +1,49 @@
<?php
/**
* @var \App\View\AppView $this
* @var iterable<\Cake\Datasource\EntityInterface> $regions
*/
?>
<div class="regions index content">
<h3><?= __('Regions') ?></h3>
<div class="table-responsive">
<table>
<thead>
<tr>
<th><?= $this->Paginator->sort('id') ?></th>
<th><?= $this->Paginator->sort('name') ?></th>
<th><?= $this->Paginator->sort('created_at') ?></th>
<th><?= $this->Paginator->sort('updated_at') ?></th>
<th><?= $this->Paginator->sort('flag') ?></th>
<th><?= $this->Paginator->sort('wikiDataId') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($regions as $region): ?>
<tr>
<td><?= $this->Number->format($region->id) ?></td>
<td><?= h($region->name) ?></td>
<td><?= h($region->created_at) ?></td>
<td><?= h($region->updated_at) ?></td>
<td><?= h($region->flag) ?></td>
<td><?= h($region->wikiDataId) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $region->id]) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->first('<< ' . __('first')) ?>
<?= $this->Paginator->prev('< ' . __('previous')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next(__('next') . ' >') ?>
<?= $this->Paginator->last(__('last') . ' >>') ?>
</ul>
<p><?= $this->Paginator->counter(__('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')) ?></p>
</div>
</div>

155
templates/Regions/view.php Normal file
View File

@ -0,0 +1,155 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $region
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('List Regions'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="regions view content">
<h3><?= h($region->name) ?></h3>
<table>
<tr>
<th><?= __('Name') ?></th>
<td><?= h($region->name) ?></td>
</tr>
<tr>
<th><?= __('WikiDataId') ?></th>
<td><?= h($region->wikiDataId) ?></td>
</tr>
<tr>
<th><?= __('Id') ?></th>
<td><?= $this->Number->format($region->id) ?></td>
</tr>
<tr>
<th><?= __('Created At') ?></th>
<td><?= h($region->created_at) ?></td>
</tr>
<tr>
<th><?= __('Updated At') ?></th>
<td><?= h($region->updated_at) ?></td>
</tr>
<tr>
<th><?= __('Flag') ?></th>
<td><?= $region->flag ? __('Yes') : __('No'); ?></td>
</tr>
</table>
<div class="text">
<strong><?= __('Translations') ?></strong>
<blockquote>
<?= $this->Text->autoParagraph(h($region->translations)); ?>
</blockquote>
</div>
<div class="related">
<h4><?= __('Related Countries') ?></h4>
<?php if (!empty($region->countries)) : ?>
<div class="table-responsive">
<table>
<tr>
<th><?= __('Id') ?></th>
<th><?= __('Name') ?></th>
<th><?= __('Iso3') ?></th>
<th><?= __('Numeric Code') ?></th>
<th><?= __('Iso2') ?></th>
<th><?= __('Phonecode') ?></th>
<th><?= __('Capital') ?></th>
<th><?= __('Currency') ?></th>
<th><?= __('Currency Name') ?></th>
<th><?= __('Currency Symbol') ?></th>
<th><?= __('Tld') ?></th>
<th><?= __('Native') ?></th>
<th><?= __('Region') ?></th>
<th><?= __('Region Id') ?></th>
<th><?= __('Subregion') ?></th>
<th><?= __('Subregion Id') ?></th>
<th><?= __('Nationality') ?></th>
<th><?= __('Timezones') ?></th>
<th><?= __('Latitude') ?></th>
<th><?= __('Longitude') ?></th>
<th><?= __('Emoji') ?></th>
<th><?= __('EmojiU') ?></th>
<th><?= __('Created At') ?></th>
<th><?= __('Updated At') ?></th>
<th><?= __('Flag') ?></th>
<th><?= __('WikiDataId') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
<?php foreach ($region->countries as $countries) : ?>
<tr>
<td><?= h($countries->id) ?></td>
<td><?= h($countries->name) ?></td>
<td><?= h($countries->iso3) ?></td>
<td><?= h($countries->numeric_code) ?></td>
<td><?= h($countries->iso2) ?></td>
<td><?= h($countries->phonecode) ?></td>
<td><?= h($countries->capital) ?></td>
<td><?= h($countries->currency) ?></td>
<td><?= h($countries->currency_name) ?></td>
<td><?= h($countries->currency_symbol) ?></td>
<td><?= h($countries->tld) ?></td>
<td><?= h($countries->native) ?></td>
<td><?= h($countries->region) ?></td>
<td><?= h($countries->region_id) ?></td>
<td><?= h($countries->subregion) ?></td>
<td><?= h($countries->subregion_id) ?></td>
<td><?= h($countries->nationality) ?></td>
<td><?= h($countries->timezones) ?></td>
<td><?= h($countries->latitude) ?></td>
<td><?= h($countries->longitude) ?></td>
<td><?= h($countries->emoji) ?></td>
<td><?= h($countries->emojiU) ?></td>
<td><?= h($countries->created_at) ?></td>
<td><?= h($countries->updated_at) ?></td>
<td><?= h($countries->flag) ?></td>
<td><?= h($countries->wikiDataId) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => 'Countries', 'action' => 'view', $countries->id]) ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<?php endif; ?>
</div>
<div class="related">
<h4><?= __('Related Subregions') ?></h4>
<?php if (!empty($region->subregions)) : ?>
<div class="table-responsive">
<table>
<tr>
<th><?= __('Id') ?></th>
<th><?= __('Name') ?></th>
<th><?= __('Region Id') ?></th>
<th><?= __('Created At') ?></th>
<th><?= __('Updated At') ?></th>
<th><?= __('Flag') ?></th>
<th><?= __('WikiDataId') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
<?php foreach ($region->subregions as $subregions) : ?>
<tr>
<td><?= h($subregions->id) ?></td>
<td><?= h($subregions->name) ?></td>
<td><?= h($subregions->region_id) ?></td>
<td><?= h($subregions->created_at) ?></td>
<td><?= h($subregions->updated_at) ?></td>
<td><?= h($subregions->flag) ?></td>
<td><?= h($subregions->wikiDataId) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => 'Subregions', 'action' => 'view', $subregions->id]) ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>

39
templates/States/add.php Normal file
View File

@ -0,0 +1,39 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $state
* @var \Cake\Collection\CollectionInterface|string[] $countries
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('List States'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="states form content">
<?= $this->Form->create($state) ?>
<fieldset>
<legend><?= __('Add State') ?></legend>
<?php
echo $this->Form->control('name');
echo $this->Form->control('country_id', ['options' => $countries]);
echo $this->Form->control('country_code');
echo $this->Form->control('fips_code');
echo $this->Form->control('iso2');
echo $this->Form->control('type');
echo $this->Form->control('latitude');
echo $this->Form->control('longitude');
echo $this->Form->control('created_at');
echo $this->Form->control('updated_at');
echo $this->Form->control('flag');
echo $this->Form->control('wikiDataId');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>

44
templates/States/edit.php Normal file
View File

@ -0,0 +1,44 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $state
* @var string[]|\Cake\Collection\CollectionInterface $countries
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $state->id],
['confirm' => __('Are you sure you want to delete # {0}?', $state->id), 'class' => 'side-nav-item']
) ?>
<?= $this->Html->link(__('List States'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="states form content">
<?= $this->Form->create($state) ?>
<fieldset>
<legend><?= __('Edit State') ?></legend>
<?php
echo $this->Form->control('name');
echo $this->Form->control('country_id', ['options' => $countries]);
echo $this->Form->control('country_code');
echo $this->Form->control('fips_code');
echo $this->Form->control('iso2');
echo $this->Form->control('type');
echo $this->Form->control('latitude');
echo $this->Form->control('longitude');
echo $this->Form->control('created_at');
echo $this->Form->control('updated_at');
echo $this->Form->control('flag');
echo $this->Form->control('wikiDataId');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>

View File

@ -0,0 +1,63 @@
<?php
/**
* @var \App\View\AppView $this
* @var iterable<\Cake\Datasource\EntityInterface> $states
*/
?>
<div class="states index content">
<h3><?= __('States') ?></h3>
<div class="table-responsive">
<table>
<thead>
<tr>
<th><?= $this->Paginator->sort('id') ?></th>
<th><?= $this->Paginator->sort('name') ?></th>
<th><?= $this->Paginator->sort('country_id') ?></th>
<th><?= $this->Paginator->sort('country_code') ?></th>
<th><?= $this->Paginator->sort('fips_code') ?></th>
<th><?= $this->Paginator->sort('iso2') ?></th>
<th><?= $this->Paginator->sort('type') ?></th>
<th><?= $this->Paginator->sort('latitude') ?></th>
<th><?= $this->Paginator->sort('longitude') ?></th>
<th><?= $this->Paginator->sort('created_at') ?></th>
<th><?= $this->Paginator->sort('updated_at') ?></th>
<th><?= $this->Paginator->sort('flag') ?></th>
<th><?= $this->Paginator->sort('wikiDataId') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($states as $state): ?>
<tr>
<td><?= $this->Number->format($state->id) ?></td>
<td><?= h($state->name) ?></td>
<td><?= $state->hasValue('country') ? $this->Html->link($state->country->name, ['controller' => 'Countries', 'action' => 'view', $state->country->id]) : '' ?></td>
<td><?= h($state->country_code) ?></td>
<td><?= h($state->fips_code) ?></td>
<td><?= h($state->iso2) ?></td>
<td><?= h($state->type) ?></td>
<td><?= $state->latitude === null ? '' : $this->Number->format($state->latitude) ?></td>
<td><?= $state->longitude === null ? '' : $this->Number->format($state->longitude) ?></td>
<td><?= h($state->created_at) ?></td>
<td><?= h($state->updated_at) ?></td>
<td><?= h($state->flag) ?></td>
<td><?= h($state->wikiDataId) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $state->id]) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->first('<< ' . __('first')) ?>
<?= $this->Paginator->prev('< ' . __('previous')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next(__('next') . ' >') ?>
<?= $this->Paginator->last(__('last') . ' >>') ?>
</ul>
<p><?= $this->Paginator->counter(__('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')) ?></p>
</div>
</div>

View File

@ -0,0 +1,13 @@
<?php
/**
* @var \App\View\AppView $this
* @var iterable<\Cake\Datasource\EntityInterface> $states
*/
$this->setLayout('ajax');
?>
<option value="">Select a state</option>
<?php foreach ($states as $stateId => $stateName): ?>
<option value="<?= $stateId; ?>" <?= $this->request->getQuery('state_id') == $stateId ? 'selected="selected"' : ''; ?>><?= $stateName; ?></option>
<?php endforeach; ?>

167
templates/States/view.php Normal file
View File

@ -0,0 +1,167 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $state
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('List States'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="states view content">
<h3><?= h($state->name) ?></h3>
<table>
<tr>
<th><?= __('Name') ?></th>
<td><?= h($state->name) ?></td>
</tr>
<tr>
<th><?= __('Country') ?></th>
<td><?= $state->hasValue('country') ? $this->Html->link($state->country->name, ['controller' => 'Countries', 'action' => 'view', $state->country->id]) : '' ?></td>
</tr>
<tr>
<th><?= __('Country Code') ?></th>
<td><?= h($state->country_code) ?></td>
</tr>
<tr>
<th><?= __('Fips Code') ?></th>
<td><?= h($state->fips_code) ?></td>
</tr>
<tr>
<th><?= __('Iso2') ?></th>
<td><?= h($state->iso2) ?></td>
</tr>
<tr>
<th><?= __('Type') ?></th>
<td><?= h($state->type) ?></td>
</tr>
<tr>
<th><?= __('WikiDataId') ?></th>
<td><?= h($state->wikiDataId) ?></td>
</tr>
<tr>
<th><?= __('Id') ?></th>
<td><?= $this->Number->format($state->id) ?></td>
</tr>
<tr>
<th><?= __('Latitude') ?></th>
<td><?= $state->latitude === null ? '' : $this->Number->format($state->latitude) ?></td>
</tr>
<tr>
<th><?= __('Longitude') ?></th>
<td><?= $state->longitude === null ? '' : $this->Number->format($state->longitude) ?></td>
</tr>
<tr>
<th><?= __('Created At') ?></th>
<td><?= h($state->created_at) ?></td>
</tr>
<tr>
<th><?= __('Updated At') ?></th>
<td><?= h($state->updated_at) ?></td>
</tr>
<tr>
<th><?= __('Flag') ?></th>
<td><?= $state->flag ? __('Yes') : __('No'); ?></td>
</tr>
</table>
<div class="related">
<h4><?= __('Related Addresses') ?></h4>
<?php if (!empty($state->addresses)) : ?>
<div class="table-responsive">
<table>
<tr>
<th><?= __('Id') ?></th>
<th><?= __('Address Name') ?></th>
<th><?= __('Contact Name') ?></th>
<th><?= __('Address Line1') ?></th>
<th><?= __('Address Line2') ?></th>
<th><?= __('City') ?></th>
<th><?= __('City Id') ?></th>
<th><?= __('State') ?></th>
<th><?= __('State Id') ?></th>
<th><?= __('Postal Code') ?></th>
<th><?= __('Country') ?></th>
<th><?= __('Country Id') ?></th>
<th><?= __('Phone Number') ?></th>
<th><?= __('Email') ?></th>
<th><?= __('Notes') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
<?php foreach ($state->addresses as $addresses) : ?>
<tr>
<td><?= h($addresses->id) ?></td>
<td><?= h($addresses->address_name) ?></td>
<td><?= h($addresses->contact_name) ?></td>
<td><?= h($addresses->address_line1) ?></td>
<td><?= h($addresses->address_line2) ?></td>
<td><?= h($addresses->city) ?></td>
<td><?= h($addresses->city_id) ?></td>
<td><?= h($addresses->state) ?></td>
<td><?= h($addresses->state_id) ?></td>
<td><?= h($addresses->postal_code) ?></td>
<td><?= h($addresses->country) ?></td>
<td><?= h($addresses->country_id) ?></td>
<td><?= h($addresses->phone_number) ?></td>
<td><?= h($addresses->email) ?></td>
<td><?= h($addresses->notes) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => 'Addresses', 'action' => 'view', $addresses->id]) ?>
<?= $this->Html->link(__('Edit'), ['controller' => 'Addresses', 'action' => 'edit', $addresses->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['controller' => 'Addresses', 'action' => 'delete', $addresses->id], ['confirm' => __('Are you sure you want to delete # {0}?', $addresses->id)]) ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<?php endif; ?>
</div>
<div class="related">
<h4><?= __('Related Cities') ?></h4>
<?php if (!empty($state->cities)) : ?>
<div class="table-responsive">
<table>
<tr>
<th><?= __('Id') ?></th>
<th><?= __('Name') ?></th>
<th><?= __('State Id') ?></th>
<th><?= __('State Code') ?></th>
<th><?= __('Country Id') ?></th>
<th><?= __('Country Code') ?></th>
<th><?= __('Latitude') ?></th>
<th><?= __('Longitude') ?></th>
<th><?= __('Created At') ?></th>
<th><?= __('Updated At') ?></th>
<th><?= __('Flag') ?></th>
<th><?= __('WikiDataId') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
<?php foreach ($state->cities as $cities) : ?>
<tr>
<td><?= h($cities->id) ?></td>
<td><?= h($cities->name) ?></td>
<td><?= h($cities->state_id) ?></td>
<td><?= h($cities->state_code) ?></td>
<td><?= h($cities->country_id) ?></td>
<td><?= h($cities->country_code) ?></td>
<td><?= h($cities->latitude) ?></td>
<td><?= h($cities->longitude) ?></td>
<td><?= h($cities->created_at) ?></td>
<td><?= h($cities->updated_at) ?></td>
<td><?= h($cities->flag) ?></td>
<td><?= h($cities->wikiDataId) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => 'Cities', 'action' => 'view', $cities->id]) ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,34 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $subregion
* @var \Cake\Collection\CollectionInterface|string[] $regions
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('List Subregions'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="subregions form content">
<?= $this->Form->create($subregion) ?>
<fieldset>
<legend><?= __('Add Subregion') ?></legend>
<?php
echo $this->Form->control('name');
echo $this->Form->control('translations');
echo $this->Form->control('region_id', ['options' => $regions]);
echo $this->Form->control('created_at');
echo $this->Form->control('updated_at');
echo $this->Form->control('flag');
echo $this->Form->control('wikiDataId');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>

View File

@ -0,0 +1,39 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $subregion
* @var string[]|\Cake\Collection\CollectionInterface $regions
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $subregion->id],
['confirm' => __('Are you sure you want to delete # {0}?', $subregion->id), 'class' => 'side-nav-item']
) ?>
<?= $this->Html->link(__('List Subregions'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="subregions form content">
<?= $this->Form->create($subregion) ?>
<fieldset>
<legend><?= __('Edit Subregion') ?></legend>
<?php
echo $this->Form->control('name');
echo $this->Form->control('translations');
echo $this->Form->control('region_id', ['options' => $regions]);
echo $this->Form->control('created_at');
echo $this->Form->control('updated_at');
echo $this->Form->control('flag');
echo $this->Form->control('wikiDataId');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>

View File

@ -0,0 +1,54 @@
<?php
/**
* @var \App\View\AppView $this
* @var iterable<\Cake\Datasource\EntityInterface> $subregions
*/
?>
<div class="subregions index content">
<?= $this->Html->link(__('New Subregion'), ['action' => 'add'], ['class' => 'button float-right']) ?>
<h3><?= __('Subregions') ?></h3>
<div class="table-responsive">
<table>
<thead>
<tr>
<th><?= $this->Paginator->sort('id') ?></th>
<th><?= $this->Paginator->sort('name') ?></th>
<th><?= $this->Paginator->sort('region_id') ?></th>
<th><?= $this->Paginator->sort('created_at') ?></th>
<th><?= $this->Paginator->sort('updated_at') ?></th>
<th><?= $this->Paginator->sort('flag') ?></th>
<th><?= $this->Paginator->sort('wikiDataId') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($subregions as $subregion): ?>
<tr>
<td><?= $this->Number->format($subregion->id) ?></td>
<td><?= h($subregion->name) ?></td>
<td><?= $subregion->hasValue('region') ? $this->Html->link($subregion->region->name, ['controller' => 'Regions', 'action' => 'view', $subregion->region->id]) : '' ?></td>
<td><?= h($subregion->created_at) ?></td>
<td><?= h($subregion->updated_at) ?></td>
<td><?= h($subregion->flag) ?></td>
<td><?= h($subregion->wikiDataId) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $subregion->id]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $subregion->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $subregion->id], ['confirm' => __('Are you sure you want to delete # {0}?', $subregion->id)]) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->first('<< ' . __('first')) ?>
<?= $this->Paginator->prev('< ' . __('previous')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next(__('next') . ' >') ?>
<?= $this->Paginator->last(__('last') . ' >>') ?>
</ul>
<p><?= $this->Paginator->counter(__('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')) ?></p>
</div>
</div>

View File

@ -0,0 +1,133 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $subregion
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('Edit Subregion'), ['action' => 'edit', $subregion->id], ['class' => 'side-nav-item']) ?>
<?= $this->Form->postLink(__('Delete Subregion'), ['action' => 'delete', $subregion->id], ['confirm' => __('Are you sure you want to delete # {0}?', $subregion->id), 'class' => 'side-nav-item']) ?>
<?= $this->Html->link(__('List Subregions'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
<?= $this->Html->link(__('New Subregion'), ['action' => 'add'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="subregions view content">
<h3><?= h($subregion->name) ?></h3>
<table>
<tr>
<th><?= __('Name') ?></th>
<td><?= h($subregion->name) ?></td>
</tr>
<tr>
<th><?= __('Region') ?></th>
<td><?= $subregion->hasValue('region') ? $this->Html->link($subregion->region->name, ['controller' => 'Regions', 'action' => 'view', $subregion->region->id]) : '' ?></td>
</tr>
<tr>
<th><?= __('WikiDataId') ?></th>
<td><?= h($subregion->wikiDataId) ?></td>
</tr>
<tr>
<th><?= __('Id') ?></th>
<td><?= $this->Number->format($subregion->id) ?></td>
</tr>
<tr>
<th><?= __('Created At') ?></th>
<td><?= h($subregion->created_at) ?></td>
</tr>
<tr>
<th><?= __('Updated At') ?></th>
<td><?= h($subregion->updated_at) ?></td>
</tr>
<tr>
<th><?= __('Flag') ?></th>
<td><?= $subregion->flag ? __('Yes') : __('No'); ?></td>
</tr>
</table>
<div class="text">
<strong><?= __('Translations') ?></strong>
<blockquote>
<?= $this->Text->autoParagraph(h($subregion->translations)); ?>
</blockquote>
</div>
<div class="related">
<h4><?= __('Related Countries') ?></h4>
<?php if (!empty($subregion->countries)) : ?>
<div class="table-responsive">
<table>
<tr>
<th><?= __('Id') ?></th>
<th><?= __('Name') ?></th>
<th><?= __('Iso3') ?></th>
<th><?= __('Numeric Code') ?></th>
<th><?= __('Iso2') ?></th>
<th><?= __('Phonecode') ?></th>
<th><?= __('Capital') ?></th>
<th><?= __('Currency') ?></th>
<th><?= __('Currency Name') ?></th>
<th><?= __('Currency Symbol') ?></th>
<th><?= __('Tld') ?></th>
<th><?= __('Native') ?></th>
<th><?= __('Region') ?></th>
<th><?= __('Region Id') ?></th>
<th><?= __('Subregion') ?></th>
<th><?= __('Subregion Id') ?></th>
<th><?= __('Nationality') ?></th>
<th><?= __('Timezones') ?></th>
<th><?= __('Translations') ?></th>
<th><?= __('Latitude') ?></th>
<th><?= __('Longitude') ?></th>
<th><?= __('Emoji') ?></th>
<th><?= __('EmojiU') ?></th>
<th><?= __('Created At') ?></th>
<th><?= __('Updated At') ?></th>
<th><?= __('Flag') ?></th>
<th><?= __('WikiDataId') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
<?php foreach ($subregion->countries as $countries) : ?>
<tr>
<td><?= h($countries->id) ?></td>
<td><?= h($countries->name) ?></td>
<td><?= h($countries->iso3) ?></td>
<td><?= h($countries->numeric_code) ?></td>
<td><?= h($countries->iso2) ?></td>
<td><?= h($countries->phonecode) ?></td>
<td><?= h($countries->capital) ?></td>
<td><?= h($countries->currency) ?></td>
<td><?= h($countries->currency_name) ?></td>
<td><?= h($countries->currency_symbol) ?></td>
<td><?= h($countries->tld) ?></td>
<td><?= h($countries->native) ?></td>
<td><?= h($countries->region) ?></td>
<td><?= h($countries->region_id) ?></td>
<td><?= h($countries->subregion) ?></td>
<td><?= h($countries->subregion_id) ?></td>
<td><?= h($countries->nationality) ?></td>
<td><?= h($countries->timezones) ?></td>
<td><?= h($countries->translations) ?></td>
<td><?= h($countries->latitude) ?></td>
<td><?= h($countries->longitude) ?></td>
<td><?= h($countries->emoji) ?></td>
<td><?= h($countries->emojiU) ?></td>
<td><?= h($countries->created_at) ?></td>
<td><?= h($countries->updated_at) ?></td>
<td><?= h($countries->flag) ?></td>
<td><?= h($countries->wikiDataId) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => 'Countries', 'action' => 'view', $countries->id]) ?>
<?= $this->Html->link(__('Edit'), ['controller' => 'Countries', 'action' => 'edit', $countries->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['controller' => 'Countries', 'action' => 'delete', $countries->id], ['confirm' => __('Are you sure you want to delete # {0}?', $countries->id)]) ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,59 @@
<?php
/**
* @var \App\View\AppView $this
* @var \Cake\Datasource\EntityInterface $address
* @var \Cake\Collection\CollectionInterface|string[] $cities
* @var \Cake\Collection\CollectionInterface|string[] $states
* @var \Cake\Collection\CollectionInterface|string[] $countries
* @var string|null $prefix
*/
$prefix = $prefix ?? '';
$stateIdId = $prefix ? str_replace('.', '-', $prefix) . 'state_id' : 'state_id';
$inputs = [
$prefix ? $prefix . 'address_name' : 'address_name' => [],
$prefix ? $prefix . 'contact_name' : 'contact_name' => [],
$prefix ? $prefix . 'address_line1' : 'address_line1' => [],
$prefix ? $prefix . 'address_line2' : 'address_line2' => [],
$prefix ? $prefix . 'city' : 'city' => [],
$prefix ? $prefix . 'city_id' : 'city_id' => [
'hidden' => true,
'options' => $cities ?? [],
'empty' => true
],
$prefix ? $prefix . 'state_id' : 'state_id' => [
'options' => $states ?? [],
'id' => $stateIdId,
'empty' => 'Select a state',
'default' => $address->state_id ?? '',
'value' => $address->state_id ?? '',
],
$prefix ? $prefix . 'postal_code' : 'postal_code' => [],
$prefix ? $prefix . 'country_id' : 'country_id' => [
'options' => $countries,
'empty' => 'Select a country',
'default' => 233,
'hx-trigger' => isset($address->id) ? 'change' : 'change, load delay:1s',
'hx-get' => $this->Url->build([
'plugin' => 'CakeAddresses',
'controller' => 'States',
'action' => 'select',
'?' => [
'state_id' => $address->state_id ?? '',
],
]),
'hx-target' => '#' . $stateIdId,
// 'hx-indicator' => '.htmx-indicator',
],
$prefix ? $prefix . 'phone_number' : 'phone_number' => [],
$prefix ? $prefix . 'email' : 'email' => [],
$prefix ? $prefix . 'notes' : 'notes' => [],
];
foreach ($inputs as $inputName => $inputOptions) {
if (array_key_exists('hidden', $inputOptions) && $inputOptions['hidden']) {
echo $this->Form->hidden($inputName, $inputOptions);
}
if (!array_key_exists('hidden', $inputOptions) || !$inputOptions['hidden']) {
echo $this->Form->control($inputName, $inputOptions);
}
}
?>

View File

View File

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
/**
* AddressesFixture
*/
class AddressesFixture extends TestFixture
{
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => 1,
'address_name' => 'Apple Headquarters',
'contact_name' => 'Steve Jobs',
'address_line1' => '1 Apple Park Way',
'address_line2' => null,
'city' => 'San Francisco',
'city_id' => 125809,
'state' => 'California',
'state_id' => 1416,
'postal_code' => '95014',
'country' => 'United States',
'country_id' => 233,
'phone_number' => 'Lorem ipsum dolor sit a',
'email' => 'test@test.com',
'notes' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida, phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin venenatis cum nullam, vivamus ut a sed, mollitia lectus. Nulla vestibulum massa neque ut et, id hendrerit sit, feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.',
],
];
parent::init();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,344 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
use PhpCollective\DecimalObject\Decimal;
use ReflectionClass;
/**
* CountriesFixture
*/
class CountriesFixture extends TestFixture
{
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => 25,
'name' => 'Bermuda',
'iso3' => 'BMU',
'numeric_code' => '060',
'iso2' => 'BM',
'phonecode' => '+1-441',
'capital' => 'Hamilton',
'currency' => 'BMD',
'currency_name' => 'Bermudian dollar',
'currency_symbol' => '$',
'tld' => '.bm',
'native' => 'Bermuda',
'region' => 'Americas',
'region_id' => 2,
'subregion' => 'Northern America',
'subregion_id' => 6,
'nationality' => 'Bermudian, Bermudan',
'timezones' => '[{"zoneName":"Atlantic/Bermuda","gmtOffset":-14400,"gmtOffsetName":"UTC-04:00","abbreviation":"AST","tzName":"Atlantic Standard Time"}]',
'translations' => '{"kr":"버뮤다","pt-BR":"Bermudas","pt":"Bermudas","nl":"Bermuda","hr":"Bermudi","fa":"برمودا","de":"Bermuda","es":"Bermudas","fr":"Bermudes","ja":"バミューダ","it":"Bermuda","cn":"百慕大","tr":"Bermuda"}',
'latitude' => (static function() {
$class = new ReflectionClass(Decimal::class);
$object = $class->newInstanceWithoutConstructor();
(function() {
$this->integralPart = '32';
$this->fractionalPart = '33333333';
$this->negative = false;
$this->scale = 8;
})->bindTo($object, Decimal::class)();
return $object;
})(),
'longitude' => (static function() {
$class = new ReflectionClass(Decimal::class);
$object = $class->newInstanceWithoutConstructor();
(function() {
$this->integralPart = '64';
$this->fractionalPart = '75000000';
$this->negative = true;
$this->scale = 8;
})->bindTo($object, Decimal::class)();
return $object;
})(),
'emoji' => '🇧🇲',
'emojiU' => 'U+1F1E7 U+1F1F2',
'created_at' => '2018-07-21 16:11:03',
'updated_at' => '2023-08-09 06:04:58',
'flag' => true,
'wikiDataId' => null,
],
[
'id' => 39,
'name' => 'Canada',
'iso3' => 'CAN',
'numeric_code' => '124',
'iso2' => 'CA',
'phonecode' => '1',
'capital' => 'Ottawa',
'currency' => 'CAD',
'currency_name' => 'Canadian dollar',
'currency_symbol' => '$',
'tld' => '.ca',
'native' => 'Canada',
'region' => 'Americas',
'region_id' => 2,
'subregion' => 'Northern America',
'subregion_id' => 6,
'nationality' => 'Canadian',
'timezones' => '[{"zoneName":"America/Atikokan","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America)"},{"zoneName":"America/Blanc-Sablon","gmtOffset":-14400,"gmtOffsetName":"UTC-04:00","abbreviation":"AST","tzName":"Atlantic Standard Time"},{"zoneName":"America/Cambridge_Bay","gmtOffset":-25200,"gmtOffsetName":"UTC-07:00","abbreviation":"MST","tzName":"Mountain Standard Time (North America)"},{"zoneName":"America/Creston","gmtOffset":-25200,"gmtOffsetName":"UTC-07:00","abbreviation":"MST","tzName":"Mountain Standard Time (North America)"},{"zoneName":"America/Dawson","gmtOffset":-25200,"gmtOffsetName":"UTC-07:00","abbreviation":"MST","tzName":"Mountain Standard Time (North America)"},{"zoneName":"America/Dawson_Creek","gmtOffset":-25200,"gmtOffsetName":"UTC-07:00","abbreviation":"MST","tzName":"Mountain Standard Time (North America)"},{"zoneName":"America/Edmonton","gmtOffset":-25200,"gmtOffsetName":"UTC-07:00","abbreviation":"MST","tzName":"Mountain Standard Time (North America)"},{"zoneName":"America/Fort_Nelson","gmtOffset":-25200,"gmtOffsetName":"UTC-07:00","abbreviation":"MST","tzName":"Mountain Standard Time (North America)"},{"zoneName":"America/Glace_Bay","gmtOffset":-14400,"gmtOffsetName":"UTC-04:00","abbreviation":"AST","tzName":"Atlantic Standard Time"},{"zoneName":"America/Goose_Bay","gmtOffset":-14400,"gmtOffsetName":"UTC-04:00","abbreviation":"AST","tzName":"Atlantic Standard Time"},{"zoneName":"America/Halifax","gmtOffset":-14400,"gmtOffsetName":"UTC-04:00","abbreviation":"AST","tzName":"Atlantic Standard Time"},{"zoneName":"America/Inuvik","gmtOffset":-25200,"gmtOffsetName":"UTC-07:00","abbreviation":"MST","tzName":"Mountain Standard Time (North America"},{"zoneName":"America/Iqaluit","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Moncton","gmtOffset":-14400,"gmtOffsetName":"UTC-04:00","abbreviation":"AST","tzName":"Atlantic Standard Time"},{"zoneName":"America/Nipigon","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Pangnirtung","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Rainy_River","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/Rankin_Inlet","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/Regina","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/Resolute","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/St_Johns","gmtOffset":-12600,"gmtOffsetName":"UTC-03:30","abbreviation":"NST","tzName":"Newfoundland Standard Time"},{"zoneName":"America/Swift_Current","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/Thunder_Bay","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Toronto","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Vancouver","gmtOffset":-28800,"gmtOffsetName":"UTC-08:00","abbreviation":"PST","tzName":"Pacific Standard Time (North America"},{"zoneName":"America/Whitehorse","gmtOffset":-25200,"gmtOffsetName":"UTC-07:00","abbreviation":"MST","tzName":"Mountain Standard Time (North America"},{"zoneName":"America/Winnipeg","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/Yellowknife","gmtOffset":-25200,"gmtOffsetName":"UTC-07:00","abbreviation":"MST","tzName":"Mountain Standard Time (North America"}]',
'translations' => '{"kr":"캐나다","pt-BR":"Canadá","pt":"Canadá","nl":"Canada","hr":"Kanada","fa":"کانادا","de":"Kanada","es":"Canadá","fr":"Canada","ja":"カナダ","it":"Canada","cn":"加拿大","tr":"Kanada"}',
'latitude' => (static function() {
$class = new ReflectionClass(Decimal::class);
$object = $class->newInstanceWithoutConstructor();
(function() {
$this->integralPart = '60';
$this->fractionalPart = '00000000';
$this->negative = false;
$this->scale = 8;
})->bindTo($object, Decimal::class)();
return $object;
})(),
'longitude' => (static function() {
$class = new ReflectionClass(Decimal::class);
$object = $class->newInstanceWithoutConstructor();
(function() {
$this->integralPart = '95';
$this->fractionalPart = '00000000';
$this->negative = true;
$this->scale = 8;
})->bindTo($object, Decimal::class)();
return $object;
})(),
'emoji' => '🇨🇦',
'emojiU' => 'U+1F1E8 U+1F1E6',
'created_at' => '2018-07-21 16:11:03',
'updated_at' => '2023-08-09 06:04:58',
'flag' => true,
'wikiDataId' => 'Q16',
],
[
'id' => 86,
'name' => 'Greenland',
'iso3' => 'GRL',
'numeric_code' => '304',
'iso2' => 'GL',
'phonecode' => '299',
'capital' => 'Nuuk',
'currency' => 'DKK',
'currency_name' => 'Danish krone',
'currency_symbol' => 'Kr.',
'tld' => '.gl',
'native' => 'Kalaallit Nunaat',
'region' => 'Americas',
'region_id' => 2,
'subregion' => 'Northern America',
'subregion_id' => 6,
'nationality' => 'Greenlandic',
'timezones' => '[{"zoneName":"America/Danmarkshavn","gmtOffset":0,"gmtOffsetName":"UTC±00","abbreviation":"GMT","tzName":"Greenwich Mean Time"},{"zoneName":"America/Nuuk","gmtOffset":-10800,"gmtOffsetName":"UTC-03:00","abbreviation":"WGT","tzName":"West Greenland Time"},{"zoneName":"America/Scoresbysund","gmtOffset":-3600,"gmtOffsetName":"UTC-01:00","abbreviation":"EGT","tzName":"Eastern Greenland Time"},{"zoneName":"America/Thule","gmtOffset":-14400,"gmtOffsetName":"UTC-04:00","abbreviation":"AST","tzName":"Atlantic Standard Time"}]',
'translations' => '{"kr":"그린란드","pt-BR":"Groelândia","pt":"Gronelândia","nl":"Groenland","hr":"Grenland","fa":"گرینلند","de":"Grönland","es":"Groenlandia","fr":"Groenland","ja":"グリーンランド","it":"Groenlandia","cn":"格陵兰岛","tr":"Grönland"}',
'latitude' => (static function() {
$class = new ReflectionClass(Decimal::class);
$object = $class->newInstanceWithoutConstructor();
(function() {
$this->integralPart = '72';
$this->fractionalPart = '00000000';
$this->negative = false;
$this->scale = 8;
})->bindTo($object, Decimal::class)();
return $object;
})(),
'longitude' => (static function() {
$class = new ReflectionClass(Decimal::class);
$object = $class->newInstanceWithoutConstructor();
(function() {
$this->integralPart = '40';
$this->fractionalPart = '00000000';
$this->negative = true;
$this->scale = 8;
})->bindTo($object, Decimal::class)();
return $object;
})(),
'emoji' => '🇬🇱',
'emojiU' => 'U+1F1EC U+1F1F1',
'created_at' => '2018-07-21 16:11:03',
'updated_at' => '2023-08-09 06:04:58',
'flag' => true,
'wikiDataId' => null,
],
[
'id' => 187,
'name' => 'Saint Pierre and Miquelon',
'iso3' => 'SPM',
'numeric_code' => '666',
'iso2' => 'PM',
'phonecode' => '508',
'capital' => 'Saint-Pierre',
'currency' => 'EUR',
'currency_name' => 'Euro',
'currency_symbol' => '€',
'tld' => '.pm',
'native' => 'Saint-Pierre-et-Miquelon',
'region' => 'Americas',
'region_id' => 2,
'subregion' => 'Northern America',
'subregion_id' => 6,
'nationality' => 'Saint-Pierrais or Miquelonnais',
'timezones' => '[{"zoneName":"America/Miquelon","gmtOffset":-10800,"gmtOffsetName":"UTC-03:00","abbreviation":"PMDT","tzName":"Pierre & Miquelon Daylight Time"}]',
'translations' => '{"kr":"생피에르 미클롱","pt-BR":"Saint-Pierre e Miquelon","pt":"São Pedro e Miquelon","nl":"Saint Pierre en Miquelon","hr":"Sveti Petar i Mikelon","fa":"سن پیر و میکلن","de":"Saint-Pierre und Miquelon","es":"San Pedro y Miquelón","fr":"Saint-Pierre-et-Miquelon","ja":"サンピエール島・ミクロン島","it":"Saint-Pierre e Miquelon","cn":"圣皮埃尔和密克隆","tr":"Saint Pierre Ve Miquelon"}',
'latitude' => (static function() {
$class = new ReflectionClass(Decimal::class);
$object = $class->newInstanceWithoutConstructor();
(function() {
$this->integralPart = '46';
$this->fractionalPart = '83333333';
$this->negative = false;
$this->scale = 8;
})->bindTo($object, Decimal::class)();
return $object;
})(),
'longitude' => (static function() {
$class = new ReflectionClass(Decimal::class);
$object = $class->newInstanceWithoutConstructor();
(function() {
$this->integralPart = '56';
$this->fractionalPart = '33333333';
$this->negative = true;
$this->scale = 8;
})->bindTo($object, Decimal::class)();
return $object;
})(),
'emoji' => '🇵🇲',
'emojiU' => 'U+1F1F5 U+1F1F2',
'created_at' => '2018-07-21 16:11:03',
'updated_at' => '2023-08-10 04:23:19',
'flag' => true,
'wikiDataId' => null,
],
[
'id' => 233,
'name' => 'United States',
'iso3' => 'USA',
'numeric_code' => '840',
'iso2' => 'US',
'phonecode' => '1',
'capital' => 'Washington',
'currency' => 'USD',
'currency_name' => 'United States dollar',
'currency_symbol' => '$',
'tld' => '.us',
'native' => 'United States',
'region' => 'Americas',
'region_id' => 2,
'subregion' => 'Northern America',
'subregion_id' => 6,
'nationality' => 'American',
'timezones' => '[{"zoneName":"America/Adak","gmtOffset":-36000,"gmtOffsetName":"UTC-10:00","abbreviation":"HST","tzName":"HawaiiAleutian Standard Time"},{"zoneName":"America/Anchorage","gmtOffset":-32400,"gmtOffsetName":"UTC-09:00","abbreviation":"AKST","tzName":"Alaska Standard Time"},{"zoneName":"America/Boise","gmtOffset":-25200,"gmtOffsetName":"UTC-07:00","abbreviation":"MST","tzName":"Mountain Standard Time (North America"},{"zoneName":"America/Chicago","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/Denver","gmtOffset":-25200,"gmtOffsetName":"UTC-07:00","abbreviation":"MST","tzName":"Mountain Standard Time (North America"},{"zoneName":"America/Detroit","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Indiana/Indianapolis","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Indiana/Knox","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/Indiana/Marengo","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Indiana/Petersburg","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Indiana/Tell_City","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/Indiana/Vevay","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Indiana/Vincennes","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Indiana/Winamac","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Juneau","gmtOffset":-32400,"gmtOffsetName":"UTC-09:00","abbreviation":"AKST","tzName":"Alaska Standard Time"},{"zoneName":"America/Kentucky/Louisville","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Kentucky/Monticello","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Los_Angeles","gmtOffset":-28800,"gmtOffsetName":"UTC-08:00","abbreviation":"PST","tzName":"Pacific Standard Time (North America"},{"zoneName":"America/Menominee","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/Metlakatla","gmtOffset":-32400,"gmtOffsetName":"UTC-09:00","abbreviation":"AKST","tzName":"Alaska Standard Time"},{"zoneName":"America/New_York","gmtOffset":-18000,"gmtOffsetName":"UTC-05:00","abbreviation":"EST","tzName":"Eastern Standard Time (North America"},{"zoneName":"America/Nome","gmtOffset":-32400,"gmtOffsetName":"UTC-09:00","abbreviation":"AKST","tzName":"Alaska Standard Time"},{"zoneName":"America/North_Dakota/Beulah","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/North_Dakota/Center","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/North_Dakota/New_Salem","gmtOffset":-21600,"gmtOffsetName":"UTC-06:00","abbreviation":"CST","tzName":"Central Standard Time (North America"},{"zoneName":"America/Phoenix","gmtOffset":-25200,"gmtOffsetName":"UTC-07:00","abbreviation":"MST","tzName":"Mountain Standard Time (North America"},{"zoneName":"America/Sitka","gmtOffset":-32400,"gmtOffsetName":"UTC-09:00","abbreviation":"AKST","tzName":"Alaska Standard Time"},{"zoneName":"America/Yakutat","gmtOffset":-32400,"gmtOffsetName":"UTC-09:00","abbreviation":"AKST","tzName":"Alaska Standard Time"},{"zoneName":"Pacific/Honolulu","gmtOffset":-36000,"gmtOffsetName":"UTC-10:00","abbreviation":"HST","tzName":"HawaiiAleutian Standard Time"}]',
'translations' => '{"kr":"미국","pt-BR":"Estados Unidos","pt":"Estados Unidos","nl":"Verenigde Staten","hr":"Sjedinjene Američke Države","fa":"ایالات متحده آمریکا","de":"Vereinigte Staaten von Amerika","es":"Estados Unidos","fr":"États-Unis","ja":"アメリカ合衆国","it":"Stati Uniti D\'America","cn":"美国","tr":"Amerika"}',
'latitude' => (static function() {
$class = new ReflectionClass(Decimal::class);
$object = $class->newInstanceWithoutConstructor();
(function() {
$this->integralPart = '38';
$this->fractionalPart = '00000000';
$this->negative = false;
$this->scale = 8;
})->bindTo($object, Decimal::class)();
return $object;
})(),
'longitude' => (static function() {
$class = new ReflectionClass(Decimal::class);
$object = $class->newInstanceWithoutConstructor();
(function() {
$this->integralPart = '97';
$this->fractionalPart = '00000000';
$this->negative = true;
$this->scale = 8;
})->bindTo($object, Decimal::class)();
return $object;
})(),
'emoji' => '🇺🇸',
'emojiU' => 'U+1F1FA U+1F1F8',
'created_at' => '2018-07-21 16:11:03',
'updated_at' => '2023-08-10 04:23:19',
'flag' => true,
'wikiDataId' => 'Q30',
],
[
'id' => 234,
'name' => 'United States Minor Outlying Islands',
'iso3' => 'UMI',
'numeric_code' => '581',
'iso2' => 'UM',
'phonecode' => '1',
'capital' => '',
'currency' => 'USD',
'currency_name' => 'United States dollar',
'currency_symbol' => '$',
'tld' => '.us',
'native' => 'United States Minor Outlying Islands',
'region' => 'Americas',
'region_id' => 2,
'subregion' => 'Northern America',
'subregion_id' => 6,
'nationality' => 'American',
'timezones' => '[{"zoneName":"Pacific/Midway","gmtOffset":-39600,"gmtOffsetName":"UTC-11:00","abbreviation":"SST","tzName":"Samoa Standard Time"},{"zoneName":"Pacific/Wake","gmtOffset":43200,"gmtOffsetName":"UTC+12:00","abbreviation":"WAKT","tzName":"Wake Island Time"}]',
'translations' => '{"kr":"미국령 군소 제도","pt-BR":"Ilhas Menores Distantes dos Estados Unidos","pt":"Ilhas Menores Distantes dos Estados Unidos","nl":"Kleine afgelegen eilanden van de Verenigde Staten","hr":"Mali udaljeni otoci SAD-a","fa":"جزایر کوچک حاشیه‌ای ایالات متحده آمریکا","de":"Kleinere Inselbesitzungen der Vereinigten Staaten","es":"Islas Ultramarinas Menores de Estados Unidos","fr":"Îles mineures éloignées des États-Unis","ja":"合衆国領有小離島","it":"Isole minori esterne degli Stati Uniti d\'America","cn":"美国本土外小岛屿","tr":"Abd Küçük Harici Adalari"}',
'latitude' => (static function() {
$class = new ReflectionClass(Decimal::class);
$object = $class->newInstanceWithoutConstructor();
(function() {
$this->integralPart = '0';
$this->fractionalPart = '00000000';
$this->negative = false;
$this->scale = 8;
})->bindTo($object, Decimal::class)();
return $object;
})(),
'longitude' => (static function() {
$class = new ReflectionClass(Decimal::class);
$object = $class->newInstanceWithoutConstructor();
(function() {
$this->integralPart = '0';
$this->fractionalPart = '00000000';
$this->negative = false;
$this->scale = 8;
})->bindTo($object, Decimal::class)();
return $object;
})(),
'emoji' => '🇺🇲',
'emojiU' => 'U+1F1FA U+1F1F2',
'created_at' => '2018-07-21 16:11:03',
'updated_at' => '2023-08-10 04:23:19',
'flag' => true,
'wikiDataId' => null,
],
];
parent::init();
}
}

View File

@ -0,0 +1,84 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
/**
* RegionsFixture
*/
class RegionsFixture extends TestFixture
{
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => 1,
'name' => 'Africa',
// 'translations' => '{"kr":"아프리카","pt-BR":"África","pt":"África","nl":"Afrika","hr":"Afrika","fa":"آفریقا","de":"Afrika","es":"África","fr":"Afrique","ja":"アフリカ","it":"Africa","cn":"非洲","tr":"Afrika"}',
'translations' => '',
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-14 14:11:03',
'flag' => true,
'wikiDataId' => 'Q15',
],
[
'id' => 2,
'name' => 'Americas',
// 'translations' => '{"kr":"아메리카","pt-BR":"América","pt":"América","nl":"Amerika","hr":"Amerika","fa":"قاره آمریکا","de":"Amerika","es":"América","fr":"Amérique","ja":"アメリカ州","it":"America","cn":"美洲","tr":"Amerika"}',
'translations' => '',
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-14 14:11:03',
'flag' => true,
'wikiDataId' => 'Q828',
],
[
'id' => 3,
'name' => 'Asia',
// 'translations' => '{"kr":"아시아","pt-BR":"Ásia","pt":"Ásia","nl":"Azië","hr":"Ázsia","fa":"آسیا","de":"Asien","es":"Asia","fr":"Asie","ja":"アジア","it":"Asia","cn":"亚洲","tr":"Asya"}',
'translations' => '',
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-14 14:11:03',
'flag' => true,
'wikiDataId' => 'Q48',
],
[
'id' => 4,
'name' => 'Europe',
// 'translations' => '{"kr":"유럽","pt-BR":"Europa","pt":"Europa","nl":"Europa","hr":"Európa","fa":"اروپا","de":"Europa","es":"Europa","fr":"Europe","ja":"ヨーロッパ","it":"Europa","cn":"欧洲","tr":"Avrupa"}',
'translations' => '',
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-14 14:11:03',
'flag' => true,
'wikiDataId' => 'Q46',
],
[
'id' => 5,
'name' => 'Oceania',
// 'translations' => '{"kr":"오세아니아","pt-BR":"Oceania","pt":"Oceania","nl":"Oceanië en Australië","hr":"Óceánia és Ausztrália","fa":"اقیانوسیه","de":"Ozeanien und Australien","es":"Oceanía","fr":"Océanie","ja":"オセアニア","it":"Oceania","cn":"大洋洲","tr":"Okyanusya"}',
'translations' => '',
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-14 14:11:03',
'flag' => true,
'wikiDataId' => 'Q55643',
],
[
'id' => 6,
'name' => 'Polar',
// 'translations' => '{"kr":"남극","pt-BR":"Antártida","pt":"Antártida","nl":"Antarctica","hr":"Antarktika","fa":"جنوبگان","de":"Antarktika","es":"Antártida","fr":"Antarctique","ja":"南極大陸","it":"Antartide","cn":"南極洲","tr":"Antarktika"}',
'translations' => '',
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-14 14:11:03',
'flag' => true,
'wikiDataId' => 'Q51',
],
];
parent::init();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,244 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
/**
* SubregionsFixture
*/
class SubregionsFixture extends TestFixture
{
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => 1,
'name' => 'Northern Africa',
'translations' => '{"korean":"북아프리카","portuguese":"Norte de África","dutch":"Noord-Afrika","croatian":"Sjeverna Afrika","persian":"شمال آفریقا","german":"Nordafrika","spanish":"Norte de África","french":"Afrique du Nord","japanese":"北アフリカ","italian":"Nordafrica","chinese":"北部非洲"}',
'region_id' => 1,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:10:23',
'flag' => true,
'wikiDataId' => 'Q27381',
],
[
'id' => 2,
'name' => 'Middle Africa',
'translations' => '{"korean":"중앙아프리카","portuguese":"África Central","dutch":"Centraal-Afrika","croatian":"Srednja Afrika","persian":"مرکز آفریقا","german":"Zentralafrika","spanish":"África Central","french":"Afrique centrale","japanese":"中部アフリカ","italian":"Africa centrale","chinese":"中部非洲"}',
'region_id' => 1,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:09',
'flag' => true,
'wikiDataId' => 'Q27433',
],
[
'id' => 3,
'name' => 'Western Africa',
'translations' => '{"korean":"서아프리카","portuguese":"África Ocidental","dutch":"West-Afrika","croatian":"Zapadna Afrika","persian":"غرب آفریقا","german":"Westafrika","spanish":"África Occidental","french":"Afrique de l\'Ouest","japanese":"西アフリカ","italian":"Africa occidentale","chinese":"西非"}',
'region_id' => 1,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:09',
'flag' => true,
'wikiDataId' => 'Q4412',
],
[
'id' => 4,
'name' => 'Eastern Africa',
'translations' => '{"korean":"동아프리카","portuguese":"África Oriental","dutch":"Oost-Afrika","croatian":"Istočna Afrika","persian":"شرق آفریقا","german":"Ostafrika","spanish":"África Oriental","french":"Afrique de l\'Est","japanese":"東アフリカ","italian":"Africa orientale","chinese":"东部非洲"}',
'region_id' => 1,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:10',
'flag' => true,
'wikiDataId' => 'Q27407',
],
[
'id' => 5,
'name' => 'Southern Africa',
'translations' => '{"korean":"남아프리카","portuguese":"África Austral","dutch":"Zuidelijk Afrika","croatian":"Južna Afrika","persian":"جنوب آفریقا","german":"Südafrika","spanish":"África austral","french":"Afrique australe","japanese":"南部アフリカ","italian":"Africa australe","chinese":"南部非洲"}',
'region_id' => 1,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:10',
'flag' => true,
'wikiDataId' => 'Q27394',
],
[
'id' => 6,
'name' => 'Northern America',
'translations' => '{"korean":"북미","portuguese":"América Setentrional","dutch":"Noord-Amerika","persian":"شمال آمریکا","german":"Nordamerika","spanish":"América Norteña","french":"Amérique septentrionale","japanese":"北部アメリカ","italian":"America settentrionale","chinese":"北美地區"}',
'region_id' => 2,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:10',
'flag' => true,
'wikiDataId' => 'Q2017699',
],
[
'id' => 7,
'name' => 'Caribbean',
'translations' => '{"korean":"카리브","portuguese":"Caraíbas","dutch":"Caraïben","croatian":"Karibi","persian":"کارائیب","german":"Karibik","spanish":"Caribe","french":"Caraïbes","japanese":"カリブ海地域","italian":"Caraibi","chinese":"加勒比地区"}',
'region_id' => 2,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:10',
'flag' => true,
'wikiDataId' => 'Q664609',
],
[
'id' => 8,
'name' => 'South America',
'translations' => '{"korean":"남아메리카","portuguese":"América do Sul","dutch":"Zuid-Amerika","croatian":"Južna Amerika","persian":"آمریکای جنوبی","german":"Südamerika","spanish":"América del Sur","french":"Amérique du Sud","japanese":"南アメリカ","italian":"America meridionale","chinese":"南美洲"}',
'region_id' => 2,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:10',
'flag' => true,
'wikiDataId' => 'Q18',
],
[
'id' => 9,
'name' => 'Central America',
'translations' => '{"korean":"중앙아메리카","portuguese":"América Central","dutch":"Centraal-Amerika","croatian":"Srednja Amerika","persian":"آمریکای مرکزی","german":"Zentralamerika","spanish":"América Central","french":"Amérique centrale","japanese":"中央アメリカ","italian":"America centrale","chinese":"中美洲"}',
'region_id' => 2,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:11',
'flag' => true,
'wikiDataId' => 'Q27611',
],
[
'id' => 10,
'name' => 'Central Asia',
'translations' => '{"korean":"중앙아시아","portuguese":"Ásia Central","dutch":"Centraal-Azië","croatian":"Srednja Azija","persian":"آسیای میانه","german":"Zentralasien","spanish":"Asia Central","french":"Asie centrale","japanese":"中央アジア","italian":"Asia centrale","chinese":"中亚"}',
'region_id' => 3,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:11',
'flag' => true,
'wikiDataId' => 'Q27275',
],
[
'id' => 11,
'name' => 'Western Asia',
'translations' => '{"korean":"서아시아","portuguese":"Sudoeste Asiático","dutch":"Zuidwest-Azië","croatian":"Jugozapadna Azija","persian":"غرب آسیا","german":"Vorderasien","spanish":"Asia Occidental","french":"Asie de l\'Ouest","japanese":"西アジア","italian":"Asia occidentale","chinese":"西亚"}',
'region_id' => 3,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:11',
'flag' => true,
'wikiDataId' => 'Q27293',
],
[
'id' => 12,
'name' => 'Eastern Asia',
'translations' => '{"korean":"동아시아","portuguese":"Ásia Oriental","dutch":"Oost-Azië","croatian":"Istočna Azija","persian":"شرق آسیا","german":"Ostasien","spanish":"Asia Oriental","french":"Asie de l\'Est","japanese":"東アジア","italian":"Asia orientale","chinese":"東亞"}',
'region_id' => 3,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:11',
'flag' => true,
'wikiDataId' => 'Q27231',
],
[
'id' => 13,
'name' => 'South-Eastern Asia',
'translations' => '{"korean":"동남아시아","portuguese":"Sudeste Asiático","dutch":"Zuidoost-Azië","croatian":"Jugoistočna Azija","persian":"جنوب شرق آسیا","german":"Südostasien","spanish":"Sudeste Asiático","french":"Asie du Sud-Est","japanese":"東南アジア","italian":"Sud-est asiatico","chinese":"东南亚"}',
'region_id' => 3,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:12',
'flag' => true,
'wikiDataId' => 'Q11708',
],
[
'id' => 14,
'name' => 'Southern Asia',
'translations' => '{"korean":"남아시아","portuguese":"Ásia Meridional","dutch":"Zuid-Azië","croatian":"Južna Azija","persian":"جنوب آسیا","german":"Südasien","spanish":"Asia del Sur","french":"Asie du Sud","japanese":"南アジア","italian":"Asia meridionale","chinese":"南亚"}',
'region_id' => 3,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:12',
'flag' => true,
'wikiDataId' => 'Q771405',
],
[
'id' => 15,
'name' => 'Eastern Europe',
'translations' => '{"korean":"동유럽","portuguese":"Europa de Leste","dutch":"Oost-Europa","croatian":"Istočna Europa","persian":"شرق اروپا","german":"Osteuropa","spanish":"Europa Oriental","french":"Europe de l\'Est","japanese":"東ヨーロッパ","italian":"Europa orientale","chinese":"东欧"}',
'region_id' => 4,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:12',
'flag' => true,
'wikiDataId' => 'Q27468',
],
[
'id' => 16,
'name' => 'Southern Europe',
'translations' => '{"korean":"남유럽","portuguese":"Europa meridional","dutch":"Zuid-Europa","croatian":"Južna Europa","persian":"جنوب اروپا","german":"Südeuropa","spanish":"Europa del Sur","french":"Europe du Sud","japanese":"南ヨーロッパ","italian":"Europa meridionale","chinese":"南欧"}',
'region_id' => 4,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:12',
'flag' => true,
'wikiDataId' => 'Q27449',
],
[
'id' => 17,
'name' => 'Western Europe',
'translations' => '{"korean":"서유럽","portuguese":"Europa Ocidental","dutch":"West-Europa","croatian":"Zapadna Europa","persian":"غرب اروپا","german":"Westeuropa","spanish":"Europa Occidental","french":"Europe de l\'Ouest","japanese":"西ヨーロッパ","italian":"Europa occidentale","chinese":"西欧"}',
'region_id' => 4,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:12',
'flag' => true,
'wikiDataId' => 'Q27496',
],
[
'id' => 18,
'name' => 'Northern Europe',
'translations' => '{"korean":"북유럽","portuguese":"Europa Setentrional","dutch":"Noord-Europa","croatian":"Sjeverna Europa","persian":"شمال اروپا","german":"Nordeuropa","spanish":"Europa del Norte","french":"Europe du Nord","japanese":"北ヨーロッパ","italian":"Europa settentrionale","chinese":"北歐"}',
'region_id' => 4,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:13',
'flag' => true,
'wikiDataId' => 'Q27479',
],
[
'id' => 19,
'name' => 'Australia and New Zealand',
'translations' => '{"korean":"오스트랄라시아","portuguese":"Australásia","dutch":"Australazië","croatian":"Australazija","persian":"استرالزی","german":"Australasien","spanish":"Australasia","french":"Australasie","japanese":"オーストララシア","italian":"Australasia","chinese":"澳大拉西亞"}',
'region_id' => 5,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:13',
'flag' => true,
'wikiDataId' => 'Q45256',
],
[
'id' => 20,
'name' => 'Melanesia',
'translations' => '{"korean":"멜라네시아","portuguese":"Melanésia","dutch":"Melanesië","croatian":"Melanezija","persian":"ملانزی","german":"Melanesien","spanish":"Melanesia","french":"Mélanésie","japanese":"メラネシア","italian":"Melanesia","chinese":"美拉尼西亚"}',
'region_id' => 5,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:13',
'flag' => true,
'wikiDataId' => 'Q37394',
],
[
'id' => 21,
'name' => 'Micronesia',
'translations' => '{"korean":"미크로네시아","portuguese":"Micronésia","dutch":"Micronesië","croatian":"Mikronezija","persian":"میکرونزی","german":"Mikronesien","spanish":"Micronesia","french":"Micronésie","japanese":"ミクロネシア","italian":"Micronesia","chinese":"密克罗尼西亚群岛"}',
'region_id' => 5,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:13',
'flag' => true,
'wikiDataId' => 'Q3359409',
],
[
'id' => 22,
'name' => 'Polynesia',
'translations' => '{"korean":"폴리네시아","portuguese":"Polinésia","dutch":"Polynesië","croatian":"Polinezija","persian":"پلی‌نزی","german":"Polynesien","spanish":"Polinesia","french":"Polynésie","japanese":"ポリネシア","italian":"Polinesia","chinese":"玻里尼西亞"}',
'region_id' => 5,
'created_at' => '2023-08-14 14:11:03',
'updated_at' => '2023-08-25 03:22:13',
'flag' => true,
'wikiDataId' => 'Q35942',
],
];
parent::init();
}
}

View File

@ -0,0 +1,481 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\TestCase\Controller;
use CakeAddresses\Controller\AddressesController;
use CakeAddresses\Model\Table\AddressesTable;
use PHPUnit\Exception;
/**
* CakeAddresses\Controller\AddressesController Test Case
*
* @uses \CakeAddresses\Controller\AddressesController
*/
class AddressesControllerTest extends BaseControllerTest
{
/**
* Addresses Table
*
* @var \CakeAddresses\Model\Table\AddressesTable
*/
protected $Addresses;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeAddresses.Addresses',
// 'plugin.CakeAddresses.Cities',
'plugin.CakeAddresses.Countries',
// 'plugin.CakeAddresses.Regions',
'plugin.CakeAddresses.States',
// 'plugin.CakeAddresses.Subregions',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$this->Addresses = $this->getTableLocator()->get('CakeAddresses.Addresses');
$this->enableCsrfToken();
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->Addresses);
parent::tearDown();
}
/**
* Test index method
*
* Tests the index action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\AddressesController::index()
* @throws Exception
*
* @return void
*/
public function testIndexGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test index method
*
* Tests the index action with a logged in user
*
* @uses \CakeAddresses\Controller\AddressesController::index()
* @throws Exception
*
* @return void
*/
public function testIndexGetLoggedIn(): void
{
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
* Test view method
*
* Tests the view action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\AddressesController::view()
* @throws Exception
*
* @return void
*/
public function testViewGetUnauthenticated(): void
{
$id = 1;
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test view method
*
* Tests the view action with a logged in user
*
* @uses \CakeAddresses\Controller\AddressesController::view()
* @throws Exception
*
* @return void
*/
public function testViewGetLoggedIn(): void
{
$id = 1;
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
* Test add method
*
* Tests the add action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\AddressesController::add()
* @throws Exception
*
* @return void
*/
public function testAddGetUnauthenticated(): void
{
$cntBefore = $this->Addresses->find()->count();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->Addresses->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test add method
*
* Tests the add action with a logged in user
*
* @uses \CakeAddresses\Controller\AddressesController::add()
* @throws Exception
*
* @return void
*/
public function testAddGetLoggedIn(): void
{
$cntBefore = $this->Addresses->find()->count();
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$cntAfter = $this->Addresses->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test add method
*
* Tests a POST request to the add action with a logged in user
*
* @uses \CakeAddresses\Controller\AddressesController::add()
* @throws Exception
*
* @return void
*/
public function testAddPostLoggedInSuccess(): void
{
$cntBefore = $this->Addresses->find()->count();
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'add',
];
$data = [
'address_name' => 'new address',
'contact_name' => 'john doe',
'address_line1' => '123 Test ST',
'address_line2' => '',
'city' => 'Seattle',
'city_id' => '',
'state_id' => 1462,
'postal_code' => '98056',
'country_id' => 233,
'phone_number' => '',
'email' => '',
'notes' => '',
];
$this->post($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('addresses');
$cntAfter = $this->Addresses->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
}
/**
* Test add method
*
* Tests a POST request to the add action with a logged in user
*
* @uses \CakeAddresses\Controller\AddressesController::add()
* @throws Exception
*
* @return void
*/
public function testAddPostLoggedInFailure(): void
{
$cntBefore = $this->Addresses->find()->count();
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'add',
];
$data = [
'address_name' => '',
'contact_name' => '',
'address_line1' => '',
'address_line2' => '',
'city' => 'Seattle',
'city_id' => '',
'state_id' => 1462,
'postal_code' => '98056',
'country_id' => 233,
'phone_number' => '',
'email' => '',
'notes' => '',
];
$this->post($url, $data);
$this->assertResponseCode(200);
$cntAfter = $this->Addresses->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test edit method
*
* Tests the edit action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\AddressesController::edit()
* @throws Exception
*
* @return void
*/
public function testEditGetUnauthenticated(): void
{
$id = 1;
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'edit',
$id,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test edit method
*
* Tests the edit action with a logged in user
*
* @uses \CakeAddresses\Controller\AddressesController::edit()
* @throws Exception
*
* @return void
*/
public function testEditGetLoggedIn(): void
{
$id = 1;
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'edit',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
* Test edit method
*
* Tests a PUT request to the edit action with a logged in user
*
* @uses \CakeAddresses\Controller\AddressesController::edit()
* @throws Exception
*
* @return void
*/
public function testEditPutLoggedInSuccess(): void
{
$this->loginUserByRole();
$id = 1;
$before = $this->Addresses->get($id);
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'edit',
$id,
];
$data = [
// test new data here
'address_name' => 'new address',
'contact_name' => 'john doe',
'address_line1' => '123 Test ST',
'address_line2' => '',
'city' => 'Seattle',
'city_id' => '',
'state_id' => 1462,
'postal_code' => '98056',
'country_id' => 233,
'phone_number' => '',
'email' => '',
'notes' => '',
];
$this->put($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('addresses');
$after = $this->Addresses->get($id);
// assert saved properly below
}
/**
* Test edit method
*
* Tests a PUT request to the edit action with a logged in user
*
* @uses \CakeAddresses\Controller\AddressesController::edit()
* @throws Exception
*
* @return void
*/
public function testEditPutLoggedInFailure(): void
{
$this->loginUserByRole();
$id = 1;
$before = $this->Addresses->get($id);
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'edit',
$id,
];
$data = [
'address_name' => '',
'contact_name' => '',
'address_line1' => '',
'address_line2' => '',
'city' => 'Seattle',
'city_id' => '',
'state_id' => 1462,
'postal_code' => '98056',
'country_id' => 233,
'phone_number' => '',
'email' => '',
'notes' => '',
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->Addresses->get($id);
// assert save failed below
}
/**
* Test delete method
*
* Tests the delete action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\AddressesController::delete()
* @throws Exception
*
* @return void
*/
public function testDeleteUnauthenticated(): void
{
$cntBefore = $this->Addresses->find()->count();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'delete',
1,
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
$cntAfter = $this->Addresses->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
}
/**
* Test delete method
*
* Tests the delete action with a logged in user
*
* @uses \CakeAddresses\Controller\AddressesController::delete()
* @throws Exception
*
* @return void
*/
public function testDeleteLoggedIn(): void
{
$cntBefore = $this->Addresses->find()->count();
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Addresses',
'action' => 'delete',
1,
];
$this->delete($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('addresses');
$cntAfter = $this->Addresses->find()->count();
$this->assertEquals($cntBefore - 1, $cntAfter);
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace CakeAddresses\Test\TestCase\Controller;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
class BaseControllerTest extends TestCase
{
use IntegrationTestTrait;
public function loginUserByRole(string $role = 'admin'): void
{
$this->session(['Auth.User.id' => 1]);
$this->session(['Auth.id' => 1]);
}
/**
* @return void
*/
public function testTest()
{
$this->assertEquals(1, 1);
}
}

View File

@ -0,0 +1,103 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\TestCase\Controller;
use CakeAddresses\Controller\CitiesController;
use PHPUnit\Exception;
/**
* CakeAddresses\Controller\CitiesController Test Case
*
* @uses \CakeAddresses\Controller\CitiesController
*/
class CitiesControllerTest extends BaseControllerTest
{
/**
* Cities Table
*
* @var \CakeAddresses\Model\Table\CitiesTable
*/
protected $Cities;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
// 'plugin.CakeAddresses.Regions',
// 'plugin.CakeAddresses.Subregions',
'plugin.CakeAddresses.Countries',
'plugin.CakeAddresses.States',
'plugin.CakeAddresses.Cities',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$this->Cities = $this->getTableLocator()->get('Cities');
$this->enableCsrfToken();
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->Cities);
parent::tearDown();
}
/**
* Test select method
*
* Tests the select action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\CitiesController::select()
* @throws Exception
*
* @return void
*/
public function testSelectGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Cities',
'action' => 'select',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test select method
*
* Tests the select action with a logged in user
*
* @uses \CakeAddresses\Controller\CitiesController::select()
* @throws Exception
*
* @return void
*/
public function testSelectGetLoggedIn(): void
{
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Cities',
'action' => 'select',
];
$this->get($url);
$this->assertResponseCode(200);
}
}

View File

@ -0,0 +1,151 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\TestCase\Controller;
use CakeAddresses\Controller\CountriesController;
use PHPUnit\Exception;
/**
* CakeAddresses\Controller\CountriesController Test Case
*
* @uses \CakeAddresses\Controller\CountriesController
*/
class CountriesControllerTest extends BaseControllerTest
{
/**
* AnsibleGroups Table
*
* @var \CakeAddresses\Model\Table\CountriesTable
*/
protected $Countries;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeAddresses.Regions',
'plugin.CakeAddresses.Subregions',
'plugin.CakeAddresses.Countries',
'plugin.CakeAddresses.States',
// 'plugin.CakeAddresses.Cities',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$this->Countries = $this->getTableLocator()->get('Countries');
$this->enableCsrfToken();
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->Countries);
parent::tearDown();
}
/**
* Test index method
*
* Tests the index action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\CountriesController::index()
* @throws Exception
*
* @return void
*/
public function testIndexGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Countries',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test index method
*
* Tests the index action with a logged in user
*
* @uses \CakeAddresses\Controller\CountriesController::index()
* @throws Exception
*
* @return void
*/
public function testIndexGetLoggedIn(): void
{
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Countries',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
* Test view method
*
* Tests the view action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\CountriesController::view()
* @throws Exception
*
* @return void
*/
public function testViewGetUnauthenticated(): void
{
$id = 233;
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Countries',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test view method
*
* Tests the view action with a logged in user
*
* @uses \CakeAddresses\Controller\CountriesController::view()
* @throws Exception
*
* @return void
*/
public function testViewGetLoggedIn(): void
{
$id = 233;
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Countries',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
}

View File

@ -0,0 +1,154 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\TestCase\Controller;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
use CakeAddresses\Controller\RegionsController;
use PHPUnit\Exception;
/**
* CakeAddresses\Controller\RegionsController Test Case
*
* @uses \CakeAddresses\Controller\RegionsController
*/
class RegionsControllerTest extends BaseControllerTest
{
/**
* Regions Table
*
* @var \CakeAddresses\Model\Table\RegionsTable
*/
protected $Regions;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeAddresses.Regions',
// 'plugin.CakeAddresses.Subregions',
// 'plugin.CakeAddresses.Countries',
// 'plugin.CakeAddresses.States',
// 'plugin.CakeAddresses.Cities',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$this->Regions = $this->getTableLocator()->get('Regions');
$this->enableCsrfToken();
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->Regions);
parent::tearDown();
}
/**
* Test index method
*
* Tests the index action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\RegionsController::index()
* @throws Exception
*
* @return void
*/
public function testIndexGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Regions',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test index method
*
* Tests the index action with a logged in user
*
* @uses \CakeAddresses\Controller\RegionsController::index()
* @throws Exception
*
* @return void
*/
public function testIndexGetLoggedIn(): void
{
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Regions',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
* Test view method
*
* Tests the view action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\RegionsController::view()
* @throws Exception
*
* @return void
*/
public function testViewGetUnauthenticated(): void
{
$id = 1;
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Regions',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test view method
*
* Tests the view action with a logged in user
*
* @uses \CakeAddresses\Controller\RegionsController::view()
* @throws Exception
*
* @return void
*/
public function testViewGetLoggedIn(): void
{
$id = 1;
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Regions',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
}

View File

@ -0,0 +1,150 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\TestCase\Controller;
use CakeAddresses\Controller\StatesController;
use PHPUnit\Exception;
/**
* CakeAddresses\Controller\StatesController Test Case
*
* @uses \CakeAddresses\Controller\StatesController
*/
class StatesControllerTest extends BaseControllerTest
{
/**
* States Table
*
* @var \CakeAddresses\Model\Table\StatesTable
*/
protected $States;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
// 'plugin.CakeAddresses.Regions',
// 'plugin.CakeAddresses.Subregions',
'plugin.CakeAddresses.Countries',
'plugin.CakeAddresses.States',
// 'plugin.CakeAddresses.Cities',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$this->States = $this->getTableLocator()->get('States');
$this->enableCsrfToken();
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->States);
parent::tearDown();
}
/**
* Test index method
*
* Tests the index action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\StatesController::index()
* @throws Exception
*
* @return void
*/
public function testIndexGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'States',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test index method
*
* Tests the index action with a logged in user
*
* @uses \CakeAddresses\Controller\StatesController::index()
* @throws Exception
*
* @return void
*/
public function testIndexGetLoggedIn(): void
{
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'States',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
* Test view method
*
* Tests the view action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\StatesController::view()
* @throws Exception
*
* @return void
*/
public function testViewGetUnauthenticated(): void
{
$id = 1462;
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'States',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test view method
*
* Tests the view action with a logged in user
*
* @uses \CakeAddresses\Controller\StatesController::view()
* @throws Exception
*
* @return void
*/
public function testViewGetLoggedIn(): void
{
$id = 1462;
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'States',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
}

View File

@ -0,0 +1,154 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\TestCase\Controller;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
use CakeAddresses\Controller\SubregionsController;
use PHPUnit\Exception;
/**
* CakeAddresses\Controller\SubregionsController Test Case
*
* @uses \CakeAddresses\Controller\SubregionsController
*/
class SubregionsControllerTest extends BaseControllerTest
{
/**
* Subregions Table
*
* @var \CakeAddresses\Model\Table\SubregionsTable
*/
protected $Subregions;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeAddresses.Regions',
'plugin.CakeAddresses.Subregions',
'plugin.CakeAddresses.Countries',
// 'plugin.CakeAddresses.States',
// 'plugin.CakeAddresses.Cities',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$this->Subregions = $this->getTableLocator()->get('Subregions');
$this->enableCsrfToken();
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->Subregions);
parent::tearDown();
}
/**
* Test index method
*
* Tests the index action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\SubregionsController::index()
* @throws Exception
*
* @return void
*/
public function testIndexGetUnauthenticated(): void
{
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Subregions',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test index method
*
* Tests the index action with a logged in user
*
* @uses \CakeAddresses\Controller\SubregionsController::index()
* @throws Exception
*
* @return void
*/
public function testIndexGetLoggedIn(): void
{
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Subregions',
'action' => 'index',
];
$this->get($url);
$this->assertResponseCode(200);
}
/**
* Test view method
*
* Tests the view action with an unauthenticated user (not logged in)
*
* @uses \CakeAddresses\Controller\SubregionsController::view()
* @throws Exception
*
* @return void
*/
public function testViewGetUnauthenticated(): void
{
$id = 1;
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Subregions',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(302);
$this->assertRedirectContains('login');
}
/**
* Test view method
*
* Tests the view action with a logged in user
*
* @uses \CakeAddresses\Controller\SubregionsController::view()
* @throws Exception
*
* @return void
*/
public function testViewGetLoggedIn(): void
{
$id = 1;
$this->loginUserByRole();
$url = [
'plugin' => 'CakeAddresses',
'controller' => 'Subregions',
'action' => 'view',
$id,
];
$this->get($url);
$this->assertResponseCode(200);
}
}

View File

@ -0,0 +1,111 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\TestCase\Model\Table;
use Cake\TestSuite\TestCase;
use CakeAddresses\Model\Table\AddressesTable;
/**
* CakeAddresses\Model\Table\AddressesTable Test Case
*/
class AddressesTableTest extends TestCase
{
/**
* Test subject
*
* @var \CakeAddresses\Model\Table\AddressesTable
*/
protected $Addresses;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeAddresses.Addresses',
'plugin.CakeAddresses.Cities',
'plugin.CakeAddresses.States',
'plugin.CakeAddresses.Countries',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('Addresses') ? [] : ['className' => AddressesTable::class];
$this->Addresses = $this->getTableLocator()->get('Addresses', $config);
}
/**
* TestInitialize method
*
* @return void
* @uses \CakeAddresses\Model\Table\AddressesTable::initialize()
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'Cities',
'States',
'Countries',
];
$associations = $this->Addresses->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->Addresses->hasAssociation($expectedAssociation), 'Failed asserting Addresses has the association: ' . $expectedAssociation);
}
// verify all behaviors loaded
$expectedBehaviors = [
];
$behaviors = $this->Addresses->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->Addresses->hasBehavior($expectedBehavior));
}
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->Addresses);
parent::tearDown();
}
/**
* Test validationDefault method
*
* @return void
* @uses \CakeAddresses\Model\Table\AddressesTable::validationDefault()
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
* @uses \CakeAddresses\Model\Table\AddressesTable::buildRules()
*/
public function testBuildRules(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,111 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\TestCase\Model\Table;
use Cake\TestSuite\TestCase;
use CakeAddresses\Model\Table\CitiesTable;
/**
* CakeAddresses\Model\Table\CitiesTable Test Case
*/
class CitiesTableTest extends TestCase
{
/**
* Test subject
*
* @var \CakeAddresses\Model\Table\CitiesTable
*/
protected $Cities;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeAddresses.Cities',
'plugin.CakeAddresses.States',
'plugin.CakeAddresses.Countries',
'plugin.CakeAddresses.Addresses',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('Cities') ? [] : ['className' => CitiesTable::class];
$this->Cities = $this->getTableLocator()->get('Cities', $config);
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->Cities);
parent::tearDown();
}
/**
* TestInitialize method
*
* @return void
* @uses \CakeAddresses\Model\Table\CitiesTable::initialize()
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'States',
'Countries',
'Addresses',
];
$associations = $this->Cities->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->Cities->hasAssociation($expectedAssociation), 'Failed asserting Cities has the association: ' . $expectedAssociation);
}
// verify all behaviors loaded
$expectedBehaviors = [
];
$behaviors = $this->Cities->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->Cities->hasBehavior($expectedBehavior));
}
}
/**
* Test validationDefault method
*
* @return void
* @uses \CakeAddresses\Model\Table\CitiesTable::validationDefault()
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
* @uses \CakeAddresses\Model\Table\CitiesTable::buildRules()
*/
public function testBuildRules(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,80 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\TestCase\Model\Table;
use Cake\TestSuite\TestCase;
use CakeAddresses\Model\Table\CountriesTable;
/**
* CakeAddresses\Model\Table\CountriesTable Test Case
*/
class CountriesTableTest extends TestCase
{
/**
* Test subject
*
* @var \CakeAddresses\Model\Table\CountriesTable
*/
protected $Countries;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeAddresses.Countries',
'plugin.CakeAddresses.Regions',
'plugin.CakeAddresses.Subregions',
'plugin.CakeAddresses.Addresses',
'plugin.CakeAddresses.Cities',
'plugin.CakeAddresses.States',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('Countries') ? [] : ['className' => CountriesTable::class];
$this->Countries = $this->getTableLocator()->get('Countries', $config);
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->Countries);
parent::tearDown();
}
/**
* Test validationDefault method
*
* @return void
* @uses \CakeAddresses\Model\Table\CountriesTable::validationDefault()
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
* @uses \CakeAddresses\Model\Table\CountriesTable::buildRules()
*/
public function testBuildRules(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,97 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\TestCase\Model\Table;
use Cake\TestSuite\TestCase;
use CakeAddresses\Model\Table\RegionsTable;
/**
* CakeAddresses\Model\Table\RegionsTable Test Case
*/
class RegionsTableTest extends TestCase
{
/**
* Test subject
*
* @var \CakeAddresses\Model\Table\RegionsTable
*/
protected $Regions;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeAddresses.Regions',
'plugin.CakeAddresses.Countries',
'plugin.CakeAddresses.Subregions',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('Regions') ? [] : ['className' => RegionsTable::class];
$this->Regions = $this->getTableLocator()->get('Regions', $config);
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->Regions);
parent::tearDown();
}
/**
* TestInitialize method
*
* @return void
* @uses \CakeAddresses\Model\Table\RegionsTable::initialize()
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [
'Countries',
'Subregions',
// 'States',
];
$associations = $this->Regions->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->Regions->hasAssociation($expectedAssociation));
}
// verify all behaviors loaded
$expectedBehaviors = [];
$behaviors = $this->Regions->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->Regions->hasBehavior($expectedBehavior));
}
}
/**
* Test validationDefault method
*
* @return void
* @uses \CakeAddresses\Model\Table\RegionsTable::validationDefault()
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,78 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\TestCase\Model\Table;
use Cake\TestSuite\TestCase;
use CakeAddresses\Model\Table\StatesTable;
/**
* CakeAddresses\Model\Table\StatesTable Test Case
*/
class StatesTableTest extends TestCase
{
/**
* Test subject
*
* @var \CakeAddresses\Model\Table\StatesTable
*/
protected $States;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeAddresses.States',
'plugin.CakeAddresses.Countries',
'plugin.CakeAddresses.Addresses',
'plugin.CakeAddresses.Cities',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('States') ? [] : ['className' => StatesTable::class];
$this->States = $this->getTableLocator()->get('States', $config);
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->States);
parent::tearDown();
}
/**
* Test validationDefault method
*
* @return void
* @uses \CakeAddresses\Model\Table\StatesTable::validationDefault()
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
* @uses \CakeAddresses\Model\Table\StatesTable::buildRules()
*/
public function testBuildRules(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
namespace CakeAddresses\Test\TestCase\Model\Table;
use Cake\TestSuite\TestCase;
use CakeAddresses\Model\Table\SubregionsTable;
/**
* CakeAddresses\Model\Table\SubregionsTable Test Case
*/
class SubregionsTableTest extends TestCase
{
/**
* Test subject
*
* @var \CakeAddresses\Model\Table\SubregionsTable
*/
protected $Subregions;
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeAddresses.Subregions',
'plugin.CakeAddresses.Regions',
'plugin.CakeAddresses.Countries',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('Subregions') ? [] : ['className' => SubregionsTable::class];
$this->Subregions = $this->getTableLocator()->get('Subregions', $config);
}
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->Subregions);
parent::tearDown();
}
/**
* Test validationDefault method
*
* @return void
* @uses \CakeAddresses\Model\Table\SubregionsTable::validationDefault()
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
* @uses \CakeAddresses\Model\Table\SubregionsTable::buildRules()
*/
public function testBuildRules(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
}

119
tests/bootstrap.php Normal file
View File

@ -0,0 +1,119 @@
<?php
declare(strict_types=1);
use Cake\Cache\Cache;
use Cake\Chronos\Chronos;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Database\Connection;
use Cake\Datasource\ConnectionManager;
use Cake\TestSuite\Fixture\SchemaLoader;
use CakeAddresses\CakeAddressesPlugin;
use CakeProducts\CakeProductsPlugin;
use Migrations\TestSuite\Migrator;
use TestApp\Controller\AppController;
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
if (!defined('WINDOWS')) {
if (DS === '\\' || substr(PHP_OS, 0, 3) === 'WIN') {
define('WINDOWS', true);
} else {
define('WINDOWS', false);
}
}
define('PLUGIN_ROOT', dirname(__DIR__));
define('ROOT', PLUGIN_ROOT . DS . 'tests' . DS . 'test_app');
define('TMP', PLUGIN_ROOT . DS . 'tmp' . DS);
define('LOGS', TMP . 'logs' . DS);
define('CACHE', TMP . 'cache' . DS);
define('APP', ROOT . DS . 'src' . DS);
define('APP_DIR', 'src');
define('CAKE_CORE_INCLUDE_PATH', PLUGIN_ROOT . '/vendor/cakephp/cakephp');
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
define('CAKE', CORE_PATH . APP_DIR . DS);
define('WWW_ROOT', PLUGIN_ROOT . DS . 'webroot' . DS);
define('TESTS', __DIR__ . DS);
define('CONFIG', TESTS . 'config' . DS);
ini_set('intl.default_locale', 'de-DE');
require PLUGIN_ROOT . '/vendor/autoload.php';
require CORE_PATH . 'config/bootstrap.php';
require CAKE . 'functions.php';
Configure::write('App', [
'namespace' => 'TestApp',
'encoding' => 'UTF-8',
'paths' => [
'testWebroot' => PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS,
'webroot' => PLUGIN_ROOT . DS . 'webroot' . DS,
'templates' => [
PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'templates' . DS,
],
],
]);
Configure::write('debug', true);
Configure::write('CakeAddresses', []);
$cache = [
'default' => [
'engine' => 'File',
'path' => CACHE,
],
'_cake_translations_' => [
'className' => 'File',
'prefix' => 'crud_myapp_cake_core_',
'path' => CACHE . 'persistent/',
'serialize' => true,
'duration' => '+10 seconds',
],
'_cake_model_' => [
'className' => 'File',
'prefix' => 'crud_my_app_cake_model_',
'path' => CACHE . 'models/',
'serialize' => 'File',
'duration' => '+10 seconds',
],
];
Cache::setConfig($cache);
class_alias(AppController::class, 'App\Controller\AppController');
Plugin::getCollection()->add(new CakeAddressesPlugin());
Chronos::setTestNow(Chronos::now());
if (!getenv('DB_URL')) {
putenv('DB_URL=sqlite:///:memory:');
}
ConnectionManager::setConfig('test', [
'className' => Connection::class,
'url' => getenv('DB_URL') ?: null,
'timezone' => 'UTC',
'quoteIdentifiers' => false,
'cacheMetadata' => true,
]);
/**
* Load schema from a SQL dump file.
*
* If your plugin does not use database fixtures you can
* safely delete this.
*
* If you want to support multiple databases, consider
* using migrations to provide schema for your plugin,
* and using \Migrations\TestSuite\Migrator to load schema.
*/
// Load a schema dump file.
//(new SchemaLoader())->loadSqlFiles('tests/schema.sql', 'test');
$migrator = new Migrator();
$migrator->run(['plugin' => 'CakeAddresses']);

View File

@ -0,0 +1 @@
<?php

1
tests/config/routes.php Normal file
View File

@ -0,0 +1 @@
<?php

43
tests/schema.php Normal file
View File

@ -0,0 +1,43 @@
<?php
/**
* Based entirely off of dereuromark's plugins as I was having trouble getting fixtures to load
* after moving the plugins outside of an existing cakephp app's plugins folder
*
* @link https://github.com/dereuromark/cakephp-tools/blob/master/tests/schema.php
*/
use Cake\Utility\Inflector;
$tables = [];
/**
* @var \DirectoryIterator<\DirectoryIterator> $iterator
*/
$iterator = new DirectoryIterator(__DIR__ . DS . 'Fixture');
foreach ($iterator as $file) {
if (!preg_match('/(\w+)Fixture.php$/', (string)$file, $matches)) {
continue;
}
$name = $matches[1];
$tableName = Inflector::underscore($name);
$class = 'CakeAddresses\\Test\\Fixture\\' . $name . 'Fixture';
try {
$object = (new ReflectionClass($class))->getProperty('fields');
} catch (ReflectionException $e) {
continue;
}
$array = $object->getDefaultValue();
$constraints = $array['_constraints'] ?? [];
$indexes = $array['_indexes'] ?? [];
unset($array['_constraints'], $array['_indexes'], $array['_options']);
$table = [
'table' => $tableName,
'columns' => $array,
'constraints' => $constraints,
'indexes' => $indexes,
];
$tables[$tableName] = $table;
}
return $tables;

1
tests/schema.sql Normal file
View File

@ -0,0 +1 @@
-- Test database schema for CakeAddresses

View File

@ -0,0 +1,39 @@
<?php
namespace TestApp;
use Cake\Http\BaseApplication;
use Cake\Http\MiddlewareQueue;
use Cake\Routing\Middleware\RoutingMiddleware;
use Cake\Routing\Route\DashedRoute;
use Cake\Routing\RouteBuilder;
class Application extends BaseApplication {
/**
* @inheritDoc
*/
public function bootstrap(): void {
$this->addPlugin('CakeAddresses');
}
/**
* @inheritDoc
*/
public function middleware(MiddlewareQueue $middleware): MiddlewareQueue {
$middleware->add(new RoutingMiddleware($this));
return $middleware;
}
public function routes(RouteBuilder $routes): void
{
parent::routes($routes); // TODO: Change the autogenerated stub
$routes->setRouteClass(DashedRoute::class);
$routes->plugin('CakeAddresses', ['path' => '/cake-addresses'], function (RouteBuilder $pluginRoutes):void {
$pluginRoutes->fallbacks();
});
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace TestApp\Controller;
use Cake\Controller\Controller;
class AppController extends Controller {
/**
* @return void
*/
public function initialize(): void {
parent::initialize();
$this->loadComponent('Flash');
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace TestApp\View;
use Cake\View\View;
/**
* @property \TinyAuth\View\Helper\AuthUserHelper $AuthUser
*/
class AppView extends View {
}

View File

@ -0,0 +1,44 @@
<?php
use Cake\Core\Configure;
use Cake\Error\Debugger;
$this->layout = 'error';
if (Configure::read('debug')):
$this->layout = 'dev_error';
$this->assign('title', $message);
$this->assign('templateName', 'error500.ctp');
$this->start('file');
?>
<?php if (!empty($error->queryString)) : ?>
<p class="notice">
<strong>SQL Query: </strong>
<?= h($error->queryString) ?>
</p>
<?php endif; ?>
<?php if (!empty($error->params)) : ?>
<strong>SQL Query Params: </strong>
<?php Debugger::dump($error->params) ?>
<?php endif; ?>
<?php if ($error instanceof Error) : ?>
<strong>Error in: </strong>
<?= sprintf('%s, line %s', str_replace(ROOT, 'ROOT', $error->getFile()), $error->getLine()) ?>
<?php endif; ?>
<?php
echo $this->element('auto_table_warning');
if (extension_loaded('xdebug')):
xdebug_print_function_stack();
endif;
$this->end();
endif;
?>
<h2><?= __d('cake', 'An Internal Error Has Occurred') ?></h2>
<p class="error">
<strong><?= __d('cake', 'Error') ?>: </strong>
<?= h($message) ?>
</p>

View File

@ -0,0 +1,6 @@
<?php
/**
* @var \App\View\AppView $this
*/
?>
<?= $this->fetch('content') ?>

View File

@ -0,0 +1,6 @@
<?php
/**
* @var \App\View\AppView $this
*/
?>
<?= $this->fetch('content') ?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 B