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.
47 lines
1.0 KiB
47 lines
1.0 KiB
12 months ago
|
<?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()
|
||
|
{
|
||
|
// 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' => $warehouse->id,
|
||
|
'Nama Gudang' => $warehouse->name,
|
||
|
'Deskripsi' => $warehouse->description,
|
||
|
'Alamat' => $warehouse->address,
|
||
|
];
|
||
|
});
|
||
|
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
public function headings(): array
|
||
|
{
|
||
|
return [
|
||
|
'No',
|
||
|
'NAMA GUDANG',
|
||
|
'DESKRIPSI',
|
||
|
'ALAMAT',
|
||
|
];
|
||
|
}
|
||
|
}
|