Initial commit: Struktur aplikasi ilycats
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports;
|
||||
|
||||
use App\Models\Medicine;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
|
||||
class MedicineImport implements ToModel, WithHeadingRow
|
||||
{
|
||||
/**
|
||||
* Memetakan setiap baris Excel ke Model Medicine.
|
||||
*/
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Medicine([
|
||||
'nama_obat' => $row['nama_obat'],
|
||||
'qty' => (float) $row['stok'], // Mendukung desimal (ml)
|
||||
'unit' => $row['satuan'] ?? 'Pcs',
|
||||
'expired_date' => isset($row['kadaluarsa']) ? \Carbon\Carbon::parse($row['kadaluarsa']) : null,
|
||||
// Kategori akan terisi otomatis oleh logic Model 'booted'
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user