| Server IP : 139.59.63.204 / Your IP : 216.73.217.62 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ubuntu-s-1vcpu-1gb-blr1-01 6.8.0-110-generic #110-Ubuntu SMP PREEMPT_DYNAMIC Thu Mar 19 15:09:20 UTC 2026 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/billing/app/Exports/ |
Upload File : |
<?php
namespace App\Exports;
use App\Models\Invoice;
use Maatwebsite\Excel\Concerns\FromCollection;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Illuminate\Support\Arr;
use Auth;
class InvoiceReportExport implements FromView
{
protected $date;
function __construct($date) {
$this->date = $date;
}
/**
* @return \Illuminate\Support\Collection
*/
public function view(): View
{
if (!empty($this->date))
{
$cust_ids = Arr::flatten(Auth::user()->customer->toArray());
$query = Invoice::query();
$query->whereIn('customer_id',$cust_ids)->where('type',1);
$brokenDate = explode(' - ', $this->date);
$startDate = $brokenDate[0];
$endDate = $brokenDate[1];
$date = $this->date;
if($startDate == $endDate){
$invoices = $query->whereDate('created_at', $startDate)->paginate(10);
}
else{
$invoices = $query->whereDate('created_at','>=', $startDate)->whereDate('created_at','<=',$endDate)->get();
}
// foreach($invoices as $invoice)
// {
// dd($invoice->lineItem);
// }
return view('report.export_report', [
'invoice' => $invoices
]);
}
}
}