Merge branch 'staging' of itcorp.primaya.id:rajif/aso into staging
This commit is contained in:
@@ -172,23 +172,45 @@ class HospitalController extends Controller
|
||||
$failedRows = [];
|
||||
|
||||
foreach ($processedData as $row) {
|
||||
$q_check = DB::table('corporate_hospitals')
|
||||
->where('code', '=', $row['code'])
|
||||
->select('code')
|
||||
->first();
|
||||
$q = DB::table('organizations')
|
||||
->where('code', '=', $row['code'])
|
||||
->where('type', '=', 'hospital')
|
||||
->where('status', '=', 'active')
|
||||
->select('id', 'code', 'name')
|
||||
->limit(1)
|
||||
->first();
|
||||
try {
|
||||
CorporateHospital::create(
|
||||
[
|
||||
'corporate_id' => $corporate_id,
|
||||
'code' => $q->code,
|
||||
'name' => $q->name,
|
||||
'organization_id' => $q->id,
|
||||
'description' => $request->description ? $request->description : null,
|
||||
]
|
||||
);
|
||||
if($q_check)
|
||||
{
|
||||
DB::table('corporate_hospitals')
|
||||
->where('code','=', $q_check->code)
|
||||
->update(
|
||||
[
|
||||
'corporate_id' => $corporate_id,
|
||||
'code' => $q->code,
|
||||
'name' => $q->name,
|
||||
'organization_id' => $q->id,
|
||||
'description' => $request->description ? $request->description : null,
|
||||
'updated_by' =>auth()->user()->id,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
CorporateHospital::create(
|
||||
[
|
||||
'corporate_id' => $corporate_id,
|
||||
'code' => $q->code,
|
||||
'name' => $q->name,
|
||||
'organization_id' => $q->id,
|
||||
'description' => $request->description ? $request->description : null,
|
||||
]
|
||||
);
|
||||
}
|
||||
$importedRows++;
|
||||
} catch (\Exception $e) {
|
||||
$failedRows[] = $row;
|
||||
|
||||
Reference in New Issue
Block a user