startDate = $startDate; $this->endDate = $endDate; } /** * @return \Illuminate\Support\Collection */ public function collection() { $data = []; $data[] = ['Laporan', $this->startDate, $this->endDate]; $data[] = ['']; $data[] = ['tanggal', 'nama karyawan', 'kontak', 'total gaji', 'jumlah item']; $items = Payroll::with('employee')->whereBetween('date', [$this->startDate, $this->endDate])->get(); foreach ($items as $item) { $data[] = [ $item->date, $item->employee->name, $item->employee->whatsapp, $item->recived, $item->item_count, ]; } return collect($data); } }