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

37 lines
1.2 KiB
PHP

<?php
namespace Modules\Business\App\Exports;
use App\Models\Product;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
class ExportCurrentStockReport implements FromView
{
public function view(): View
{
$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'));
}
}