update marketing
All checks were successful
All checks were successful
This commit is contained in:
@@ -10,13 +10,27 @@ class ExportCurrentStockReport implements FromView
|
||||
{
|
||||
public function view(): View
|
||||
{
|
||||
return view('business::reports.stocks.excel-csv', [
|
||||
'stock_reports' => Product::with('stocks')
|
||||
->where('business_id', auth()->user()->business_id)
|
||||
->where('product_type', '!=', 'combo')
|
||||
->withSum('stocks', 'productStock')
|
||||
->latest()
|
||||
->get()
|
||||
]);
|
||||
$productsQuery = Product::with(['stocks' => function ($q) {
|
||||
$q->select('id', 'product_id', 'productStock', 'productPurchasePrice', 'productSalePrice');
|
||||
}])
|
||||
->where('business_id', auth()->user()->business_id)
|
||||
->where('product_type', '!=', 'combo');
|
||||
|
||||
if (request('search')) {
|
||||
$productsQuery->where(function ($q) {
|
||||
$q->where('productName', 'like', '%' . request('search') . '%')
|
||||
->orWhereHas('stocks', function ($stock) {
|
||||
$stock->where('productSalePrice', 'like', '%' . request('search') . '%')
|
||||
->orWhere('productPurchasePrice', 'like', '%' . request('search') . '%');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$stock_reports = $productsQuery
|
||||
->latest()
|
||||
->limit($request->per_page ?? 20)
|
||||
->get();
|
||||
|
||||
return view('business::reports.stocks.excel-csv', compact('stock_reports'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user