|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Exports;
|
|
|
|
|
|
|
|
use App\Models\Peti;
|
|
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
|
|
|
|
|
|
class PetternLotPetiExport implements FromCollection, WithHeadings
|
|
|
|
{
|
|
|
|
public function collection()
|
|
|
|
{
|
|
|
|
// Ambil data dari model Peti
|
|
|
|
$petis = Peti::select(
|
|
|
|
'customer_id',
|
|
|
|
'warehouse_id',
|
|
|
|
'jumlah',
|
|
|
|
'tipe_peti_id',
|
|
|
|
'packing_no',
|
|
|
|
'fix_lot',
|
|
|
|
'status'
|
|
|
|
)->get();
|
|
|
|
|
|
|
|
// Inisialisasi nomor awal
|
|
|
|
$nomor = 1;
|
|
|
|
|
|
|
|
// Modifikasi data dan tambahkan nomor
|
|
|
|
$data = $petis->map(function ($peti) use (&$nomor) {
|
|
|
|
return [
|
|
|
|
'No' => $nomor++,
|
|
|
|
'Customer' => $peti->customer->name,
|
|
|
|
'Warehouse' => $peti->warehouse->name,
|
|
|
|
'CODE CUSTOMER' => $peti->customer->code_customer,
|
|
|
|
'TYPE PETI' => $peti->tipe_peti->type,
|
|
|
|
'UKURAN PETI' => $peti->tipe_peti->size_peti,
|
|
|
|
'LOT NO' => $peti->customer->lot_no,
|
|
|
|
'PACKING NO' => $peti->packing_no,
|
|
|
|
'FIX LOT' => $peti->fix_lot,
|
|
|
|
'Status' => $peti->status,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function headings(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'No',
|
|
|
|
'Customer',
|
|
|
|
'WH',
|
|
|
|
'CODE CUSTOMER',
|
|
|
|
'TYPE PETI',
|
|
|
|
'UKURAN PETI',
|
|
|
|
'LOT NO',
|
|
|
|
'PACKING NO',
|
|
|
|
'FIX LOT',
|
|
|
|
'STATUS'
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|