Update Doctor Resource
This commit is contained in:
50
database/seeders/UpdateOrganizationCities.php
Normal file
50
database/seeders/UpdateOrganizationCities.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\District;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UpdateOrganizationCities extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$organizations = Organization::with('currentAddress')->get();
|
||||
|
||||
$districtsMap = [
|
||||
'ORG000C' => "367111",
|
||||
'ORG000D' => "327504",
|
||||
'ORG000E' => "317105",
|
||||
'ORG000F' => "737109",
|
||||
'ORG000M' => "327501",
|
||||
'ORG000O' => "732402",
|
||||
'ORG000P' => "327503",
|
||||
'ORG000Q' => "321503",
|
||||
'ORG000N' => "627103",
|
||||
'ORG000SG' => "337410",
|
||||
'ORG000BW' => "197104",
|
||||
'ORG000SK' => "320233",
|
||||
'ORG000PK' => "360312",
|
||||
'ORG000CK' => "317106",
|
||||
];
|
||||
|
||||
foreach ($organizations as $organization) {
|
||||
$district = District::with([
|
||||
'city',
|
||||
'city.province'
|
||||
])->find($districtsMap[$organization->code]);
|
||||
|
||||
$organization->currentAddress->district_id = $district->id ?? null;
|
||||
$organization->currentAddress->city_id = $district->city->id ?? null;
|
||||
$organization->currentAddress->province_id = $district->city->province->id ?? null;
|
||||
$organization->currentAddress->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user