select(' leads.*, insurers.name as insurer_name, insurer_branch.branch_name as insurer_branch_name, tpa.name as tpa_name, tpa_branch.branch_name as tpa_branch_name, policy_type.policy_type, rfq.json, rfq.registration_json ') ->join('leads', 'rfq.lead_id = leads.id') ->join('policy_type', 'leads.policy_type_id = policy_type.id') ->join('insurers', 'leads.insurer_id = insurers.id', 'left') ->join('insurer_branch', 'leads.insurer_branch_id = insurer_branch.id', 'left') ->join('tpa', 'leads.tpa_id = tpa.id', 'left') ->join('tpa_branch', 'leads.tpa_branch_id = tpa_branch.id', 'left') ->where('rfq.lead_id', $lead_id) // ->where('rfq.type', $type) ->where('rfq.is_active', 1) ->orderBy('rfq.id', 'desc') ->first(); } }