Siopas Inventory PETI for ISTW Website
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.
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Exports;
|
|
|
|
|
|
|
|
use App\Models\m_warehouse;
|
|
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
|
|
|
|
|
|
class WarehouseExport implements FromCollection, WithHeadings
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Support\Collection
|
|
|
|
*/
|
|
|
|
public function collection()
|
|
|
|
{
|
|
|
|
$nomor = 1;
|
|
|
|
// Ambil data dari model Peti
|
|
|
|
$warehouses = m_warehouse::select(
|
|
|
|
'id',
|
|
|
|
'name',
|
|
|
|
'description',
|
|
|
|
'address',
|
|
|
|
)->get();
|
|
|
|
|
|
|
|
// Modifikasi data dan tambahkan nomor
|
|
|
|
$data = $warehouses->map(function ($warehouse) use (&$nomor) {
|
|
|
|
return [
|
|
|
|
'No' => $nomor++,
|
|
|
|
'Nama Gudang' => $warehouse->name,
|
|
|
|
'Deskripsi' => $warehouse->description,
|
|
|
|
'Alamat' => $warehouse->address,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function headings(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'No',
|
|
|
|
'NAMA GUDANG',
|
|
|
|
'DESKRIPSI',
|
|
|
|
'ALAMAT',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|