37 lines
779 B
PHP
37 lines
779 B
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use App\Models\SoalPilgan;
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
|
|
class SoalPilganExport implements FromCollection, WithHeadings
|
|
{
|
|
protected $ujian_id;
|
|
|
|
public function __construct($ujian_id)
|
|
{
|
|
$this->ujian_id = $ujian_id;
|
|
}
|
|
|
|
public function collection()
|
|
{
|
|
return SoalPilgan::where('ujian_id', $this->ujian_id)
|
|
->select('pertanyaan', 'opsi_a', 'opsi_b', 'opsi_c', 'opsi_d', 'jawaban_benar')
|
|
->get();
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'Pertanyaan',
|
|
'Opsi A',
|
|
'Opsi B',
|
|
'Opsi C',
|
|
'Opsi D',
|
|
'Jawaban Benar',
|
|
];
|
|
}
|
|
}
|