fix organization seeder

This commit is contained in:
Muhammad Fajar
2022-11-04 14:30:41 +07:00
parent 3b996192a6
commit 56a998dffa

View File

@@ -16,20 +16,20 @@ class OrganizationSeeder extends Seeder
*/ */
public function run() public function run()
{ {
$response = Http::get('https://api.primaya.id/temp/organizations'); $response = Http::get('https://app.primaya.id/temp/organizations');
foreach ($response->json()['organizations'] as $organization) { foreach ($response->json()['organizations'] as $organization) {
$newOrganization = Organization::updateOrCreate([ $newOrganization = Organization::updateOrCreate([
'code' => 'ORG000'.$organization['code'], 'code' => 'ORG000' . $organization['code'],
],[ ], [
'code' => 'ORG000'.$organization['code'], 'code' => 'ORG000' . $organization['code'],
'name' => $organization['name'], 'name' => $organization['name'],
'type' => 'hospital', 'type' => 'hospital',
]); ]);
$newAddress = $newOrganization->addresses()->updateOrCreate([ $newAddress = $newOrganization->addresses()->updateOrCreate([
'id' => $newOrganization->main_address_id 'id' => $newOrganization->main_address_id
],[ ], [
'use' => 'both', 'use' => 'both',
'type' => 'physical', 'type' => 'physical',
'text' => $organization['address'], 'text' => $organization['address'],
@@ -49,14 +49,15 @@ class OrganizationSeeder extends Seeder
]); ]);
$newOrganization->metas()->updateOrCreate([ $newOrganization->metas()->updateOrCreate([
'type' => 'phone', 'type' => 'phone',
],[ ], [
'system' => 'default', 'system' => 'default',
'type' => 'phone', 'type' => 'phone',
'value' => $organization['phone'] 'value' => $organization['phone']
]); ]);
$newOrganization->metas()->updateOrCreate([ $newOrganization->metas()->updateOrCreate([
'type' => 'timezone', 'type' => 'timezone',
],['system' => 'default', ], [
'system' => 'default',
'type' => 'timezone', 'type' => 'timezone',
'value' => $organization['timezone'] 'value' => $organization['timezone']
]); ]);