diff --git a/Plugin.php b/Plugin.php index 6e798b4..6a05d9e 100644 --- a/Plugin.php +++ b/Plugin.php @@ -97,6 +97,16 @@ public function registerNavigation() 'icon' => 'icon-database', 'url' => Backend::url('winter/test/locations'), ], + 'cities' => [ + 'label' => 'Cities', + 'icon' => 'icon-database', + 'url' => Backend::url('october/test/cities'), + ], + 'locations' => [ + 'label' => 'Locations', + 'icon' => 'icon-database', + 'url' => Backend::url('october/test/locations'), + ], ], ], ]; diff --git a/models/city/columns.yaml b/models/city/columns.yaml index ac57c2f..1c24e71 100644 --- a/models/city/columns.yaml +++ b/models/city/columns.yaml @@ -6,7 +6,7 @@ columns: name: label: Name searchable: true - + country_name: label: Country relation: country diff --git a/models/city/fields.yaml b/models/city/fields.yaml index 41e7b67..ab6cb6f 100644 --- a/models/city/fields.yaml +++ b/models/city/fields.yaml @@ -15,4 +15,4 @@ fields: label: Country type: relation span: right - \ No newline at end of file + diff --git a/updates/seed_tables.php b/updates/seed_tables.php index b54a5e2..85b05ad 100644 --- a/updates/seed_tables.php +++ b/updates/seed_tables.php @@ -133,6 +133,33 @@ public function run() ['country_id' => $country2->id, 'city_id' => 8, 'name' => '2322 Xray Alphabet'], ]); + /* + * Test 9: Locations + */ + $cities = [ + $country1->id => ['Regina', 'Vancouver', 'Toronto', 'Ottawa'], + $country2->id => ['New York', 'Seattle', 'Boston', 'San Francisco'], + ]; + + $insertCities = []; + foreach ($cities as $countryId => $cityNames) { + foreach ($cityNames as $name) { + $insertCities[] = ['country_id' => $countryId, 'name' => $name]; + } + } + + City::insert($insertCities); + Location::insert([ + ['country_id' => $country1->id, 'city_id' => 1, 'name' => '240 5th Ave'], + ['country_id' => $country1->id, 'city_id' => 2, 'name' => '101 McKay Street'], + ['country_id' => $country1->id, 'city_id' => 3, 'name' => '123 Nowhere Lane'], + ['country_id' => $country1->id, 'city_id' => 4, 'name' => '10099 Bob Loop'], + ['country_id' => $country2->id, 'city_id' => 5, 'name' => '9442 Scary Street'], + ['country_id' => $country2->id, 'city_id' => 6, 'name' => '5309 Imagination Crescrent'], + ['country_id' => $country2->id, 'city_id' => 7, 'name' => '22 2201 Seymour Drive'], + ['country_id' => $country2->id, 'city_id' => 8, 'name' => '2322 Xray Alphabet'], + ]); + /* * Test 5: Reviews */