fix(cities): perbaiki pemetaan nama provinsi untuk kota
- Memperbarui pemetaan nama provinsi berdasarkan kode kota tertentu. - Menambahkan logika untuk menetapkan nama provinsi jika kode kota termasuk dalam daftar tertentu. - Mengubah referensi dari `$row->province->name` menjadi `$row->province_name` untuk konsistensi. fix(districts): perbaiki pemetaan nama provinsi untuk distrik - Memperbarui pemetaan nama provinsi berdasarkan kode kota dalam distrik. - Menambahkan logika untuk menetapkan nama provinsi jika kode kota termasuk dalam daftar tertentu. - Mengubah referensi dari `$row->city->province->name` menjadi `$row->province_name` untuk konsistensi. fix(villages): perbaiki pemetaan nama provinsi untuk desa - Memperbarui pemetaan nama provinsi berdasarkan kode kota dalam desa. - Menambahkan logika untuk menetapkan nama provinsi jika kode kota termasuk dalam daftar tertentu. - Mengubah referensi dari `$row->district->city->province->name` menjadi `$row->province_name` untuk konsistensi.
This commit is contained in:
@@ -11,7 +11,18 @@ use Modules\Location\Models\City;
|
|||||||
class CitiesExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
class CitiesExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
{
|
{
|
||||||
public function collection(){
|
public function collection(){
|
||||||
return City::with('province')->get();
|
$data = City::with('province')->get();
|
||||||
|
|
||||||
|
$data = $data->map(function ($item) {
|
||||||
|
if (in_array($item->code, ['92.01', '92.04', '92.05', '92.09', '92.10', '92.71'])) {
|
||||||
|
$item->province_name = Province::where('code', '92.1')->first()->name;
|
||||||
|
} else {
|
||||||
|
$item->province_name = $item->province->name;
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
});
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function map($row): array{
|
public function map($row): array{
|
||||||
@@ -19,7 +30,7 @@ class CitiesExport implements WithColumnFormatting, WithHeadings, FromCollection
|
|||||||
$row->id,
|
$row->id,
|
||||||
$row->code,
|
$row->code,
|
||||||
$row->name,
|
$row->name,
|
||||||
$row->province->name,
|
$row->province_name,
|
||||||
$row->created_at
|
$row->created_at
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,21 @@ use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
|||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
use Modules\Location\Models\District;
|
use Modules\Location\Models\District;
|
||||||
|
use Modules\Location\Models\Province;
|
||||||
|
|
||||||
class DistrictsExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
class DistrictsExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
{
|
{
|
||||||
public function collection(){
|
public function collection(){
|
||||||
return District::with('city.province')->get();
|
$data = District::with('city.province')->get();
|
||||||
|
|
||||||
|
$data = $data->map(function ($item) {
|
||||||
|
if (in_array($item->city_code, ['92.01', '92.04', '92.05', '92.09', '92.10', '92.71'])) {
|
||||||
|
$item->province_name = Province::where('code', '92.1')->first()->name;
|
||||||
|
} else {
|
||||||
|
$item->province_name = $item->city->province->name;
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function map($row): array{
|
public function map($row): array{
|
||||||
@@ -20,7 +30,7 @@ class DistrictsExport implements WithColumnFormatting, WithHeadings, FromCollect
|
|||||||
$row->code,
|
$row->code,
|
||||||
$row->name,
|
$row->name,
|
||||||
$row->city->name,
|
$row->city->name,
|
||||||
$row->city->province->name,
|
$row->province_name,
|
||||||
$row->created_at
|
$row->created_at
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,22 @@ use Maatwebsite\Excel\Concerns\FromCollection;
|
|||||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Location\Models\Province;
|
||||||
use Modules\Location\Models\Village;
|
use Modules\Location\Models\Village;
|
||||||
|
|
||||||
class VillagesExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
class VillagesExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
{
|
{
|
||||||
public function collection(){
|
public function collection(){
|
||||||
return Village::with('district.city.province')->get();
|
$data = Village::with('district.city.province')->get();
|
||||||
|
|
||||||
|
$data = $data->map(function ($item) {
|
||||||
|
if (in_array($item->city_code, ['92.01', '92.04', '92.05', '92.09', '92.10', '92.71'])) {
|
||||||
|
$item->province_name = Province::where('code', '92.1')->first()->name;
|
||||||
|
} else {
|
||||||
|
$item->province_name = $item->district->city->province->name;
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function map($row): array{
|
public function map($row): array{
|
||||||
@@ -22,7 +32,7 @@ class VillagesExport implements WithColumnFormatting, WithHeadings, FromCollecti
|
|||||||
$row->postal_code,
|
$row->postal_code,
|
||||||
$row->district->name,
|
$row->district->name,
|
||||||
$row->district->city->name,
|
$row->district->city->name,
|
||||||
$row->district->city->province->name,
|
$row->province_name,
|
||||||
$row->created_at
|
$row->created_at
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user