You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.0 KiB
37 lines
1.0 KiB
<?php |
|
|
|
namespace App\Imports; |
|
|
|
use App\Models\Peti; |
|
use Illuminate\Support\Collection; |
|
use Illuminate\Support\Facades\Auth; |
|
use Maatwebsite\Excel\Concerns\ToModel; |
|
use Maatwebsite\Excel\Concerns\ToCollection; |
|
use Maatwebsite\Excel\Concerns\WithHeadingRow; |
|
|
|
class PetiImport implements ToModel, WithHeadingRow |
|
{ |
|
/** |
|
* @param array $row |
|
* |
|
* @return \Illuminate\Database\Eloquent\Model|null |
|
*/ |
|
public function model(array $row) |
|
{ |
|
// Mendapatkan informasi pengguna yang sedang login |
|
$user = Auth::user(); |
|
|
|
return new Peti([ |
|
'created_by' => $user->fullname, |
|
'tipe_peti_id' => $row['tipe_peti_id'], |
|
'warna' => $row['warna'], |
|
'customer_id' => $row['customer_id'], |
|
'warehouse_id' => $row['warehouse_id'], |
|
'date_pembuatan' => now(), |
|
'kondisipeti_id' => $row['kondisipeti_id'], |
|
'packing_no' => $row['packing_no'], |
|
'fix_lot' => $row['fix_lot'], |
|
'status' => $row['status'], |
|
]); |
|
} |
|
}
|
|
|