session()->get('user.business_id'); } public function getBusiness(): ?Business { $businessId = $this->getBusinessId(); return $businessId ? Business::find($businessId) : null; } public function getSuppliersDropdown(?int $businessId = null): array { $businessId = $businessId ?? $this->getBusinessId(); return Contact::suppliersDropdown($businessId, false); } public function getProductsDropdown(?int $businessId = null): array { $businessId = $businessId ?? $this->getBusinessId(); return Product::where('business_id', $businessId) ->where('is_inactive', 0) ->orderBy('name') ->pluck('name', 'id') ->toArray(); } public function jsonOrRedirect($request, bool $success, string $message, $redirect = null) { if ($request->ajax() || $request->wantsJson()) { return response()->json(['success' => $success, 'msg' => $message]); } return redirect($redirect ?? url()->previous()) ->with('status', ['success' => $success, 'msg' => $message]); } public function riskBadgeClass(string $riskLevel): string { return match ($riskLevel) { 'low' => 'label-success', 'medium' => 'label-warning', 'high' => 'label-danger', default => 'label-default', }; } public function rfqStatusBadgeClass(string $status): string { return match ($status) { 'open' => 'label-info', 'awarded' => 'label-success', 'closed' => 'label-default', 'cancelled' => 'label-danger', default => 'label-warning', }; } }