Files
kulakpos_web/Modules/Business/App/Exports/ExportBillWisePofit.php
eko54r 05fd3230b8
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 5m14s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 17s
Build, Push and Deploy / deploy-staging (push) Successful in 41s
Build, Push and Deploy / deploy-production (push) Has been skipped
update marketing
2026-05-14 11:55:22 +07:00

46 lines
1.5 KiB
PHP

<?php
namespace Modules\Business\App\Exports;
use App\Models\Sale;
use App\Traits\DateFilterTrait;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
class ExportBillWisePofit implements FromView
{
use DateFilterTrait;
public function view(): View
{
$salesQuery = Sale::with('party:id,name')
->where('business_id', auth()->user()->business_id);
$salesQuery->when(request('search'), function ($query) {
$query->where(function ($q) {
$q->where('lossProfit', 'like', '%' . request('search') . '%')
->orWhere('totalAmount', 'like', '%' . request('search') . '%')
->orWhere('invoiceNumber', 'like', '%' . request('search') . '%')
->orWhereHas('party', function ($q) {
$q->where('name', 'like', '%' . request('search') . '%');
});
});
});
$salesQuery->when(request('party_id'), function ($query, $partyId) {
if ($partyId === 'Guest') {
$query->whereNull('party_id');
} else {
$query->where('party_id', $partyId);
}
});
$duration = request('custom_days') ?: 'today';
$this->applyDateFilter($salesQuery, $duration, 'saleDate', request('from_date'), request('to_date'));
$profits = $salesQuery->latest()->limit(request('per_page') ?? 20)->get();
return view('business::bill-wise-profits.excel-csv', compact('profits'));
}
}