private function exist($id) { $this->row = $this->model->get($id); if (!$this->row) { $this->flashMessage($this->translator->translate('admin.text.itemNotExist'), 'error'); $this->redirect('default'); } }
/** * 获取用户统计信息 * * @param int $flage 默认0,获取所有用户;1,获取已激活用户;2,获取未激活用户; * * @return mixed */ public function num_active_unactive($flage = 0) { $users = User::get(); //已激活用户 $active_user = array(); //未激活用户 $unactive_user = array(); //计数 $active_num = 0; $unactive_num = 0; foreach ($users as $k => $kValue) { //dump($kValue); $email = $kValue->email; $credentials0 = ["email" => $email]; $temp_user_info = Sentinel::findByCredentials($credentials0); if (Activation::completed($temp_user_info)) { $users[$k]['active'] = 1; $active_user[] = $users[$k]; ++$active_num; } else { $users[$k]['active'] = 0; $unactive_user[] = $users[$k]; ++$unactive_num; } } if ($flage == 1) { $users = $active_user; } if ($flage == 2) { $users = $unactive_user; } $data['active_num'] = number_format($active_num * 100 / ($active_num + $unactive_num), 2, '.', ''); $data['unactive_num'] = number_format($unactive_num * 100 / ($active_num + $unactive_num), 2, '.', ''); return $data; }
function getAll() { //return User::select('id', 'name')->get(); return User::get(); }
/** * 获取当前用户列表 * * @param int $flage 默认0,获取所有用户;1,获取已激活用户;2,获取未激活用户; * * @return mixed */ public function list_logic($flage = 0) { $users = User::get(); $current_user = Sentinel::getUser(); $current_user_id = $current_user->id; //已激活用户 $active_user = array(); //未激活用户 $unactive_user = array(); //计数 $active_num = 0; $unactive_num = 0; foreach ($users as $k => $kValue) { //dump($kValue); $email = $kValue->email; $role = $this->role_by_user($kValue); // dump($role); if (!$role) { $users[$k]['role'] = null; } else { $users[$k]['role'] = $role->slug; } $credentials0 = ["email" => $email]; $temp_user_info = Sentinel::findByCredentials($credentials0); if (Activation::completed($temp_user_info)) { $users[$k]['active'] = 1; $active_user[] = $users[$k]; ++$active_num; //当前账号 if ($current_user_id == $temp_user_info['id']) { $users[$k]['active'] = 2; } } else { $users[$k]['active'] = 0; $unactive_user[] = $users[$k]; ++$unactive_num; } } if ($flage == 1) { $users = $active_user; } if ($flage == 2) { $users = $unactive_user; } return $users; }