// +---------------------------------------------------------------------- namespace app\portal\controller; use app\portal\model\UserinfoModel; use cmf\controller\HomeBaseController; class IndexController extends HomeBaseController { public function index() { $this->getList(); return $this->fetch(':index'); } private function getList() { $m_u = new UserinfoModel(); $list = $m_u->getlist(); $list = $list->toArray(); foreach ($list as $key => $value) { $userid = $value['id']; $worktype = $m_u->getworktype($userid); if (empty($worktype)) { $worktype = [['workertypedisstr' => '普工']]; } $list[$key]['worktype'] = $worktype; } // var_dump($list); $this->assign('list', $list); } }