where('province_id', $province_id)->where(['operations_level'=>1])->find(); $city=$model->where('city_id', $city_id)->where(['operations_level'=>2])->find(); $area=$model->where('area_id', $area_id)->where(['operations_level'=>3])->find(); $data=['province_user_id'=>0,'city_user_id'=>0,'area_user_id'=>0]; if ($province){ $data['province_user_id']=$province['user_id']; } if($city){ $data['city_user_id']=$city['user_id']; } if($area){ $data['area_user_id']=$area['user_id']; } return $data; } }