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.
46 lines
1.0 KiB
46 lines
1.0 KiB
<?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(); |
|
|
|
// 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', |
|
]; |
|
} |
|
}
|
|
|