MIF_E31222467/pos-smartphone-fix/app/Exports/IncomeExport.php

41 lines
1.1 KiB
PHP

<?php
namespace App\Exports;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
class IncomeExport implements FromCollection, WithHeadings
{
protected $bulan;
protected $tahun;
public function __construct($bulan, $tahun)
{
$this->bulan = $bulan;
$this->tahun = $tahun;
}
public function collection()
{
return DB::table('cashiers')
->join('products', 'cashiers.produk_id', '=', 'products.id')
->select(
'products.nama_produk as Nama_Produk',
'cashiers.jumlah_item as Jumlah_Item',
'cashiers.total as Total_Bayar',
'cashiers.tipe_bayar as Metode_Bayar',
'cashiers.createdAt as Waktu_Tanggal'
)
->whereMonth('cashiers.createdAt', $this->bulan)
->whereYear('cashiers.createdAt', $this->tahun)
->get();
}
public function headings(): array
{
return ['Nama Produk', 'Jumlah Item', 'Total Bayar', 'Metode Bayar', 'Waktu Tanggal'];
}
}