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.

50 lines
1.1 KiB

12 months ago
<?php
namespace App\Exports;
use App\Models\Type_peti;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\FromCollection;
class TipePetiExport implements FromCollection, WithHeadings
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
// Ambil data dari model Peti
$tipepetis = Type_peti::select(
'id',
'type',
'size_peti',
'description',
)->get();
// Inisialisasi nomor awal
// $nomor = 1;
// Modifikasi data dan tambahkan nomor
$data = $tipepetis->map(function ($tipepeti) use (&$nomor) {
return [
'No' => $tipepeti->id,
'Tipe' => $tipepeti->type,
'Ukuran Peti' => $tipepeti->size_peti,
'Deskripsi' => $tipepeti->description,
];
});
return $data;
}
public function headings(): array
{
return [
'No',
'TIPE',
'UKURAN PETI',
'DESKRIPSI',
];
}
}