tambah kolom import drugs

This commit is contained in:
Linksehat Staging Server
2024-06-03 09:08:11 +07:00
parent 6ce4282a3b
commit 5e0d0cac1b
2 changed files with 7 additions and 6 deletions

View File

@@ -135,7 +135,7 @@ class DrugController extends Controller
]);
}
}
public function downloadTemplate()
public function downloadTemplate()
{
return Helper::responseJson([
'file_name' => "Template - Drugs.xlsx",
@@ -149,7 +149,6 @@ class DrugController extends Controller
$data = Excel::toArray([], $file);
$processedData = $this->processCategoryNames($data);
$importedRows = 0;
$failedRows = [];
@@ -170,6 +169,7 @@ class DrugController extends Controller
'type' => $row['type'],
'dosage' => $row['dosage'],
'remark' => $row['remark'],
'price' => $row['price'],
]
);
$importedRows++;
@@ -201,7 +201,7 @@ class DrugController extends Controller
$row[] = $data[0][$i];
$header[] = $data[0][0];
}
$filed = [];
foreach ($header[0] as $value)
{
@@ -212,16 +212,16 @@ class DrugController extends Controller
$filed[] = $modelColumn;
}
}
$result = [];
foreach ($row as $subarray) {
$trimmedSubarray = [];
for ($i = 0; $i < count($filed); $i++) {
$trimmedSubarray[$filed[$i]] = $subarray[$i] ? $subarray[$i] : null;
}
$result[] = $trimmedSubarray;
}
return $result;
}
}
}

View File

@@ -26,6 +26,7 @@ class Drug extends Model
'remark',
'selling_unit_id',
'status',
'price',
'active',
];