本文整理匯總了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;
}