Files
kulakpos_web/Modules/Business/App/Exports/ExportTransaction.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

52 lines
1.9 KiB
PHP

<?php
namespace Modules\Business\App\Exports;
use App\Models\DueCollect;
use App\Traits\DateFilterTrait;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
class ExportTransaction implements FromView
{
use DateFilterTrait;
public function view(): View
{
$businessId = auth()->user()->business_id;
$transactionsQuery = DueCollect::with('party:id,name,type', 'payment_type:id,name', 'transactions')->where('business_id', $businessId);
// Date Filter
$duration = request('custom_days') ?: 'today';
$this->applyDateFilter($transactionsQuery, $duration, 'paymentDate', request('from_date'), request('to_date'));
// Search Filter
if (request('search')) {
$transactionsQuery->where(function ($query) {
$query->where('paymentType', 'like', '%' . request('search') . '%')
->orWhere('totalDue', 'like', '%' . request('search') . '%')
->orWhere('invoiceNumber', 'like', '%' . request('search') . '%')
->orWhere('payDueAmount', 'like', '%' . request('search') . '%')
->orWhereHas('party', function ($q) {
$q->where('name', 'like', '%' . request('search') . '%');
})
->orWhereHas('payment_type', function ($q) {
$q->where('name', 'like', '%' . request('search') . '%');
});
});
}
if (request('type')) {
$transactionsQuery->whereHas('party', function ($q) {
$q->where(function ($q) {
$q->where('type', request('type'));
});
});
}
$transactions = $transactionsQuery->latest()->limit(request('per_page'))->get();
return view('business::reports.transaction-history.excel-csv', compact('transactions'));
}
}