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.
44 lines
1021 B
44 lines
1021 B
12 months ago
|
<?php
|
||
|
|
||
|
namespace App\Exports;
|
||
|
|
||
|
use App\Models\Kondisi_Peti;
|
||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||
|
|
||
|
class KondisiPetiExport implements FromCollection, WithHeadings
|
||
|
{
|
||
|
/**
|
||
|
* @return \Illuminate\Support\Collection
|
||
|
*/
|
||
|
public function collection()
|
||
|
{
|
||
|
// Ambil data dari model Peti
|
||
|
$kondisipetis = Kondisi_Peti::select(
|
||
|
'id',
|
||
|
'nama_kondisi',
|
||
|
'deskripsi_kondisi',
|
||
|
)->get();
|
||
|
|
||
|
// Modifikasi data dan tambahkan nomor
|
||
|
$data = $kondisipetis->map(function ($kondisipeti) use (&$nomor) {
|
||
|
return [
|
||
|
'No' => $kondisipeti->id,
|
||
|
'Nama Kondisi' => $kondisipeti->nama_kondisi,
|
||
|
'Deskripsi' => $kondisipeti->deskripsi_kondisi,
|
||
|
];
|
||
|
});
|
||
|
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
public function headings(): array
|
||
|
{
|
||
|
return [
|
||
|
'No',
|
||
|
'NAMA KONDISI',
|
||
|
'DESKRIPSI',
|
||
|
];
|
||
|
}
|
||
|
}
|