feat(datatable): Filter Vouchers, Purchases, and Stock Opname by user outlets for enhanced data visibility and management.
This commit is contained in:
parent
c1acb637b9
commit
44b7358768
@ -134,6 +134,11 @@ public function columns(): array
|
||||
|
||||
public function builder(): Builder
|
||||
{
|
||||
return Voucher::select('id', 'name', 'code', 'tags', 'min_purchase', 'discount_amount', 'max_discount', 'quota', 'available_count', 'limit_per_user', 'start_date', 'end_date', 'type', 'created_at')->with('outlets');
|
||||
return Voucher::select('id', 'name', 'code', 'tags', 'min_purchase', 'discount_amount', 'max_discount', 'quota', 'available_count', 'limit_per_user', 'start_date', 'end_date', 'type', 'created_at')
|
||||
->with('outlets')
|
||||
->whereHas(
|
||||
'outlets',
|
||||
fn ($q) => $q->whereIn('outlets.id', auth()->user()->outlets()->pluck('outlets.id'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,6 +78,8 @@ public function columns(): array
|
||||
|
||||
public function builder(): Builder
|
||||
{
|
||||
return Purchase::select('purchases.id', 'outlet_id', 'invoice_number', 'purchase_date', 'total')->with('outlet');
|
||||
return Purchase::select('purchases.id', 'outlet_id', 'invoice_number', 'purchase_date', 'total')
|
||||
->with('outlet')
|
||||
->whereIn('outlet_id', auth()->user()->outlets->pluck('id')->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,6 +51,7 @@ public function builder(): Builder
|
||||
{
|
||||
return StockOpname::select('stock_opname.id', 'outlet_id', 'period_month')
|
||||
->where('period_month', '!=', now()->format('Y-m'))
|
||||
->with('outlet');
|
||||
->with('outlet')
|
||||
->whereIn('outlet_id', auth()->user()->outlets->pluck('id')->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user