add trash && fixed order

This commit is contained in:
vedatakd 2020-03-31 09:57:31 +03:00
parent 01044aae52
commit 90e5171318
16 changed files with 35 additions and 33 deletions

View File

@ -35,19 +35,20 @@ class VisiosoftModuleLocationCreateLocationFields extends Migration
"default_value" => 0, "default_value" => 0,
] ]
], ],
'parent_city' => [ 'parent_country_id' => 'anomaly.field_type.integer',
'parent_city_id' => [
"type" => "anomaly.field_type.select", "type" => "anomaly.field_type.select",
"config" => [ "config" => [
"options" => [], "options" => [],
] ]
], ],
'parent_district' => [ 'parent_district_id' => [
"type" => "anomaly.field_type.select", "type" => "anomaly.field_type.select",
"config" => [ "config" => [
"options" => [], "options" => [],
] ]
], ],
'parent_neighborhood' => [ 'parent_neighborhood_id' => [
"type" => "anomaly.field_type.select", "type" => "anomaly.field_type.select",
"config" => [ "config" => [
"options" => [], "options" => [],

View File

@ -14,7 +14,7 @@ class VisiosoftModuleLocationCreateCountriesStream extends Migration
'slug' => 'countries', 'slug' => 'countries',
'title_column' => 'name', 'title_column' => 'name',
'translatable' => true, 'translatable' => true,
'trashable' => false, 'trashable' => true,
'searchable' => false, 'searchable' => false,
'sortable' => false, 'sortable' => false,
]; ];

View File

@ -14,7 +14,7 @@ class VisiosoftModuleLocationCreateCitiesStream extends Migration
'slug' => 'cities', 'slug' => 'cities',
'title_column' => 'name', 'title_column' => 'name',
'translatable' => true, 'translatable' => true,
'trashable' => false, 'trashable' => true,
'searchable' => false, 'searchable' => false,
'sortable' => false, 'sortable' => false,
]; ];
@ -33,7 +33,7 @@ class VisiosoftModuleLocationCreateCitiesStream extends Migration
'unique' => true, 'unique' => true,
'required' => true, 'required' => true,
], ],
'parent_country' => [ 'parent_country_id' => [
'required' => true, 'required' => true,
], ],
'order' 'order'

View File

@ -14,7 +14,7 @@ class VisiosoftModuleLocationCreateDistrictsStream extends Migration
'slug' => 'districts', 'slug' => 'districts',
'title_column' => 'name', 'title_column' => 'name',
'translatable' => true, 'translatable' => true,
'trashable' => false, 'trashable' => true,
'searchable' => false, 'searchable' => false,
'sortable' => false, 'sortable' => false,
]; ];
@ -33,7 +33,7 @@ class VisiosoftModuleLocationCreateDistrictsStream extends Migration
'unique' => true, 'unique' => true,
'required' => true, 'required' => true,
], ],
'parent_city' => [ 'parent_city_id' => [
'required' => true, 'required' => true,
], ],
'order' 'order'

View File

@ -14,7 +14,7 @@ class VisiosoftModuleLocationCreateNeighborhoodsStream extends Migration
'slug' => 'neighborhoods', 'slug' => 'neighborhoods',
'title_column' => 'name', 'title_column' => 'name',
'translatable' => true, 'translatable' => true,
'trashable' => false, 'trashable' => true,
'searchable' => false, 'searchable' => false,
'sortable' => false, 'sortable' => false,
]; ];
@ -33,7 +33,7 @@ class VisiosoftModuleLocationCreateNeighborhoodsStream extends Migration
'unique' => true, 'unique' => true,
'required' => true, 'required' => true,
], ],
'parent_district' => [ 'parent_district_id' => [
'required' => true, 'required' => true,
], ],
'order' 'order'

View File

@ -14,7 +14,7 @@ class VisiosoftModuleLocationCreateVillageStream extends Migration
'slug' => 'village', 'slug' => 'village',
'title_column' => 'name', 'title_column' => 'name',
'translatable' => true, 'translatable' => true,
'trashable' => false, 'trashable' => true,
'searchable' => false, 'searchable' => false,
'sortable' => false, 'sortable' => false,
]; ];
@ -33,7 +33,7 @@ class VisiosoftModuleLocationCreateVillageStream extends Migration
'unique' => true, 'unique' => true,
'required' => true, 'required' => true,
], ],
'parent_neighborhood' => [ 'parent_neighborhood_id' => [
'required' => true, 'required' => true,
], ],
'order' 'order'

View File

@ -15,13 +15,13 @@ class CityModel extends LocationCitiesEntryModel implements CityInterface
} }
public function getSubCities($country) { public function getSubCities($country) {
return $this->query()->where('parent_country_id', $country)->get(); return $this->query()->where('parent_country_id', $country)->orderBy('order','ASC')->get();
} }
public function deleteCitiesByCountry($id) { public function deleteCitiesByCountry($id) {
$districts = new DistrictModel(); $districts = new DistrictModel();
$city = $this->where('parent_country_id',$id); $city = $this->where('parent_country_id',$id);
$city_id = $city->get(); $city_id = $city->orderBy('id','DESC')->get();
foreach ($city_id as $item) foreach ($city_id as $item)
{ {
$districts->deleteDistrictByCity($item->id); $districts->deleteDistrictByCity($item->id);

View File

@ -61,7 +61,7 @@ class CityTableBuilder extends TableBuilder
*/ */
protected $options = [ protected $options = [
'order_by' => [ 'order_by' => [
'sort_order' => 'ASC', 'order' => 'ASC',
], ],
]; ];

View File

@ -61,7 +61,7 @@ class CountryTableBuilder extends TableBuilder
*/ */
protected $options = [ protected $options = [
'order_by' => [ 'order_by' => [
'sort_order' => 'ASC', 'order' => 'ASC',
], ],
]; ];

View File

@ -11,13 +11,13 @@ class DistrictModel extends LocationDistrictsEntryModel implements DistrictInter
} }
public function getSubDistricts($city) { public function getSubDistricts($city) {
return $this->query()->where('parent_city_id', $city)->get(); return $this->query()->where('parent_city_id', $city)->orderBy('order','ASC')->get();
} }
public function deleteDistrictByCity($id) { public function deleteDistrictByCity($id) {
$neighborhood = new NeighborhoodModel(); $neighborhood = new NeighborhoodModel();
$districts = $this->where('parent_city_id',$id); $districts = $this->where('parent_city_id',$id);
$districts_id = $districts->get(); $districts_id = $districts->orderBy('id','DESC')->get();
foreach ($districts_id as $item) foreach ($districts_id as $item)
{ {
$neighborhood->deleteNeighborhoodByDistrict($item->id); $neighborhood->deleteNeighborhoodByDistrict($item->id);

View File

@ -61,7 +61,7 @@ class DistrictTableBuilder extends TableBuilder
*/ */
protected $options = [ protected $options = [
'order_by' => [ 'order_by' => [
'sort_order' => 'ASC', 'order' => 'ASC',
], ],
]; ];

View File

@ -1,4 +1,5 @@
<?php namespace Visiosoft\LocationModule; <?php namespace Visiosoft\LocationModule;
use Anomaly\Streams\Platform\Database\Seeder\Seeder; use Anomaly\Streams\Platform\Database\Seeder\Seeder;
use Anomaly\Streams\Platform\Model\Options\OptionsAdvertisementEntryModel; use Anomaly\Streams\Platform\Model\Options\OptionsAdvertisementEntryModel;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
@ -19,17 +20,17 @@ class LocationModuleSeeder extends Seeder
{ {
//Download demo SQL //Download demo SQL
$repository = "https://raw.githubusercontent.com/openclassify/Openclassify-Demo-Data/master/"; $repository = "https://raw.githubusercontent.com/openclassify/Openclassify-Demo-Data/master/";
file_put_contents(__DIR__."/countries.sql", fopen($repository."countries.sql", 'r')); file_put_contents(__DIR__ . "/countries.sql", fopen($repository . "countries.sql", 'r'));
file_put_contents(__DIR__."/cities.sql", fopen($repository."cities.sql", 'r')); file_put_contents(__DIR__ . "/cities.sql", fopen($repository . "cities.sql", 'r'));
file_put_contents(__DIR__."/districts.sql", fopen($repository."districts.sql", 'r')); file_put_contents(__DIR__ . "/districts.sql", fopen($repository . "districts.sql", 'r'));
file_put_contents(__DIR__."/neighborhoods.sql", fopen($repository."neighborhoods.sql", 'r')); file_put_contents(__DIR__ . "/neighborhoods.sql", fopen($repository . "neighborhoods.sql", 'r'));
/* Demo Start */ /* Demo Start */
Model::unguard(); Model::unguard();
DB::unprepared(file_get_contents(__DIR__.'/countries.sql')); DB::unprepared(file_get_contents(__DIR__ . '/countries.sql'));
DB::unprepared(file_get_contents(__DIR__.'/cities.sql')); DB::unprepared(file_get_contents(__DIR__ . '/cities.sql'));
// DB::unprepared(file_get_contents(__DIR__.'/districts.sql')); DB::unprepared(file_get_contents(__DIR__ . '/districts.sql'));
// DB::unprepared(file_get_contents(__DIR__.'/neighborhoods.sql')); // DB::unprepared(file_get_contents(__DIR__ . '/neighborhoods.sql'));
Model::reguard(); Model::reguard();
/* Demo Stop*/ /* Demo Stop*/
} }

View File

@ -11,13 +11,13 @@ class NeighborhoodModel extends LocationNeighborhoodsEntryModel implements Neigh
} }
public function getSubNeighborhoods($district) { public function getSubNeighborhoods($district) {
return $this->query()->where('parent_district_id', $district)->get(); return $this->query()->where('parent_district_id', $district)->orderBy('order','ASC')->get();
} }
public function deleteNeighborhoodByDistrict($id) { public function deleteNeighborhoodByDistrict($id) {
$village = new VillageModel(); $village = new VillageModel();
$neighborhood = $this->where('parent_district_id',$id); $neighborhood = $this->where('parent_district_id',$id);
$neighborhoods_id = $neighborhood->get(); $neighborhoods_id = $neighborhood->orderBy('id','DESC')->get();
foreach ($neighborhoods_id as $item) foreach ($neighborhoods_id as $item)
{ {
$village->deleteVillageByNeighborhood($item->id); $village->deleteVillageByNeighborhood($item->id);

View File

@ -61,7 +61,7 @@ class NeighborhoodTableBuilder extends TableBuilder
*/ */
protected $options = [ protected $options = [
'order_by' => [ 'order_by' => [
'sort_order' => 'ASC', 'order' => 'ASC',
], ],
]; ];

View File

@ -52,7 +52,7 @@ class VillageTableBuilder extends TableBuilder
*/ */
protected $options = [ protected $options = [
'order_by' => [ 'order_by' => [
'sort_order' => 'ASC', 'order' => 'ASC',
], ],
]; ];
/** /**

View File

@ -10,10 +10,10 @@ class VillageModel extends LocationVillageEntryModel implements VillageInterface
} }
public function getSubVillages($neighborhood) { public function getSubVillages($neighborhood) {
return $this->query()->where('parent_neighborhood_id', $neighborhood)->get(); return $this->query()->where('parent_neighborhood_id', $neighborhood)->orderBy('order','ASC')->get();
} }
public function deleteVillageByNeighborhood($id) { public function deleteVillageByNeighborhood($id) {
$this->where('parent_neighborhood_id',$id)->delete(); $this->where('parent_neighborhood_id',$id)->orderBy('id','DESC')->delete();
} }
} }