update marketing
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

This commit is contained in:
2026-05-14 11:55:22 +07:00
parent f80fcc4c1b
commit 05fd3230b8
448 changed files with 17545 additions and 5128 deletions

View File

@@ -5,6 +5,7 @@
use App\Models\Product;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Services\PdfService;
use Maatwebsite\Excel\Facades\Excel;
use Modules\Business\App\Exports\ExportExpiredProduct;
@@ -64,4 +65,38 @@ public function exportCsv()
{
return Excel::download(new ExportExpiredProduct, 'expired-products.csv');
}
public function exportPdf(Request $request)
{
$expired_products = Product::with('unit:id,unitName', 'brand:id,brandName', 'category:id,categoryName', 'stocks')
->where('business_id', auth()->user()->business_id)
->withSum('stocks as total_stock', 'productStock')
->whereHas('stocks', function ($query) {
$query->whereDate('expire_date', '<', today())
->where('productStock', '>', 0);
})
->when($request->search, function ($q) use ($request) {
$q->where(function ($q) use ($request) {
$q->where('type', 'like', '%' . $request->search . '%')
->orWhere('productName', 'like', '%' . $request->search . '%')
->orWhere('productCode', 'like', '%' . $request->search . '%')
->orWhere('hsn_code', 'like', '%' . $request->search . '%')
->orWhere('productSalePrice', 'like', '%' . $request->search . '%')
->orWhere('productPurchasePrice', 'like', '%' . $request->search . '%')
->orWhereHas('unit', function ($q) use ($request) {
$q->where('unitName', 'like', '%' . $request->search . '%');
})
->orWhereHas('brand', function ($q) use ($request) {
$q->where('brandName', 'like', '%' . $request->search . '%');
})
->orWhereHas('category', function ($q) use ($request) {
$q->where('categoryName', 'like', '%' . $request->search . '%');
});
});
})
->latest()
->limit($request->per_page ?? 20)->get();
return PdfService::render('business::expired-products.pdf', compact('expired_products'),'expired-products.pdf');
}
}