insert($data); } else { // Update existing record return $this->update($id, $data); } } public function getOrganizationBranches($businessId) { // Assuming your branches table is named 'branches' $db = db_connect(); $builder = $db->table('business_branches'); $branches = $builder->where('business_id', $businessId)->get()->getResultArray(); return $branches; } }