本文整理汇总了PHP中App\Model\User::get方法的典型用法代码示例。如果您正苦于以下问题:PHP User::get方法的具体用法?PHP User::get怎么用?PHP User::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Model\User
的用法示例。
在下文中一共展示了User::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exist
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');
}
}
示例2: num_active_unactive
/**
* 获取用户统计信息
*
* @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;
}
示例3: getAll
function getAll()
{
//return User::select('id', 'name')->get();
return User::get();
}
示例4: list_logic
/**
* 获取当前用户列表
*
* @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;
}