Pick data from 2 tables and display it to the user

I want to pick data from 2 tables and create one final table which am to display to the user .How can I do that in filament?
1 Reply
codeartisan
codeartisan4mo ago
thank you everyone this fixed
$balancingQuery = Balancing::query()
->where('business_id', auth()->user()->business_id)
->where('branch_id', auth()->user()->branch_id)
->whereDate('date', $today) // Filter by today's date
->select('customer_id', 'deductable_advance as amount', 'date')
->orderBy('created_at');

$cashPaymentQuery = CashPayment::query()
->where('business_id', auth()->user()->business_id)
->where('branch_id', auth()->user()->branch_id)
->whereDate('date', $today) // Filter by today's date
->select('customer_id', 'amount', 'date')
->orderBy('created_at');

$combinedQuery = $balancingQuery->union($cashPaymentQuery);
$balancingQuery = Balancing::query()
->where('business_id', auth()->user()->business_id)
->where('branch_id', auth()->user()->branch_id)
->whereDate('date', $today) // Filter by today's date
->select('customer_id', 'deductable_advance as amount', 'date')
->orderBy('created_at');

$cashPaymentQuery = CashPayment::query()
->where('business_id', auth()->user()->business_id)
->where('branch_id', auth()->user()->branch_id)
->whereDate('date', $today) // Filter by today's date
->select('customer_id', 'amount', 'date')
->orderBy('created_at');

$combinedQuery = $balancingQuery->union($cashPaymentQuery);