本文整理汇总了PHP中app\models\User::get方法的典型用法代码示例。如果您正苦于以下问题:PHP User::get方法的具体用法?PHP User::get怎么用?PHP User::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIndex
public function getIndex(Request $request)
{
$Model = new User();
$Total = $Model->get()->count();
$Model = $Model->orderBy('id', 'DESC');
$data = $this->paging($Model, $request);
$totals = ['total' => $Total];
return $this->ResponseData($data, $totals);
}
示例2: authenticate
public static function authenticate(User $user)
{
$data = $user->get(["username" => $user->getUsername(), "password" => $user->getPassword()])->First();
if ($data != null) {
\Framework\Http\Session::instance()->Add("authenticated", true);
\Framework\Http\Session::instance()->Add("userId", $data->getId());
\Framework\Http\Session::instance()->Add("username", $data->getUsername());
}
}
示例3: validate
/**
* This validation is not great, but good enough. The Session
* environment has already been validated, so all you need is a
* valid user ID.
*/
public function validate()
{
$login = parent::validate();
if (is_array($login) && isset($login['user_id'], $login['salt'])) {
try {
$this->save(array('user' => models\User::get($login['user_id']), 'salt' => $login['salt']));
} catch (Exception $ex) {
}
}
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
if (Role::get()->count() == 0) {
Role::create(['name' => 'admin', 'display_name' => 'Admin', 'description' => 'User can adminstrate the site']);
Role::create(['name' => 'user', 'display_name' => 'User', 'description' => 'User can navigate the site']);
}
if (User::get()->count() == 0) {
User::create(['name' => env('ROOT_USER_NAME', 'Test User'), 'email' => env('ROOT_USER_EMAIL', 'testuser@test.com'), 'password' => Hash::make(env('ROOT_USER_PASSWORD', 'password'))])->attachRole(Role::where('name', '=', 'admin')->first());
}
}
示例5: check
/**
* Check if a user is logged in for the given portal
*/
public static function check()
{
if (Session::has('user_id')) {
$user = User::get();
if ($user) {
return TRUE;
}
}
return FALSE;
}
示例6: listUsers
public function listUsers()
{
if ($this->auth->check()) {
if (in_array($this->auth->user()->role, ['admin', 'judge', 'observer'])) {
$users = User::get();
return view('pages/users/list', compact('users'));
}
}
return redirect('');
}
示例7: handle
/**
* Handle the event.
*
* @param NewDiaryEvent $event
* @return void
*/
public function handle(NewDiaryEvent $event)
{
$diary = $event->diary;
$users = User::get(['id', 'name', 'email']);
foreach ($users as $user) {
$user = $user->toArray();
Mail::queue('email.new_diary', ['diary' => $diary->toArray(), 'author' => $diary->user->toArray(), 'user' => $user], function ($m) use($user) {
$m->to($user['email'], $user['name'])->subject("A new diary was published! Welcome to nahid.co ");
});
}
}
示例8: anyIndex
public function anyIndex()
{
$user_id = NULL;
if (User::check()) {
$user_id = User::get()->id;
}
$website_views = new WebsiteViews();
$website_views->user_id = $user_id;
$website_views->save();
return View::make('home.home');
}
示例9: validate
public function validate()
{
$login = parent::validate();
if (is_array($login) && isset($login['user_id'], $login['salt'])) {
try {
$this->user = models\User::get($login['user_id'], array('unicheck' => $login['unicheck']));
$this->salt = $login['salt'];
$this->user->update(array('last_access' => time()));
} catch (Exception $ex) {
$this->logout();
}
}
}
示例10: delete
public function delete()
{
if ($this->request->id) {
$user = User::get($this->request->id);
$user->delete();
$this->message('Success to delete User');
$this->redirect('Users::index');
return true;
}
$this->message('User id cannot be empty');
$this->redirect($this->request->referer());
return false;
}
示例11: __construct
public function __construct()
{
// Require that the user is a guest (logged out)
$this->middleware('guest', ['only' => ['getLogin', 'postLogin']]);
// Require that the user is logged in
$this->middleware('auth', ['only' => ['getLogout', 'getProfile']]);
if (User::get()) {
// $this->roles = User::get()->checkRole(Seller::get()->id, User::get()->id);
$this->super_admin = User::get()->isSuperAdmin(User::$user->id);
}
// View::share('user_roles', $this->roles);
View::share('super_admin', $this->super_admin);
}
示例12: bind
public function bind($user_id)
{
$user = User::get($user_id);
if (!$user) {
throw new NotFoundHttpException();
} else {
return $user;
}
// $sid = Input::get('sid');
// if (!$this->isValid($user_id, $sid)) {
// throw new NotFoundHttpException;
// }
// return User::get($user_id);
}
示例13: findAdmins
/**
* Get list (collection) of Admin(s)
*/
function findAdmins($field = 'all')
{
$users = User::get();
$admins = [];
foreach ($users as $user) {
if ($user->isAdmin()) {
if ($field == 'all') {
array_push($admins, $user);
} else {
array_push($admins, $user[$field]);
}
}
}
return $admins;
}
示例14: postSetup
/**
* Get the setup page.
*
* @return View
*/
protected function postSetup(Request $request)
{
$user = User::get()->first();
if ($user) {
abort('403', 'Setup already finished');
}
$validator = Validator::make($request->all(), ['name' => 'required', 'email' => 'required|email|unique:users,email', 'cas_username' => 'unique:users,cas_username', 'password' => 'required|min:8']);
if ($validator->fails()) {
return Redirect::action('Pages\\PageController@getSetup')->withInput()->withErrors($validator);
}
$user = new User();
$user->name = $request->name;
$user->email = $request->email;
$user->password = Hash::make($request->password);
$user->cas_username = $request->cas_username;
$user->super_admin = true;
$user->save();
return Redirect::action('User\\UserController@getDashboard', $user->id)->with('status', 'Setup finished');
}
示例15: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Conversation::truncate();
DB::table('conversation_user')->truncate();
$users = User::get();
foreach ($users as $user) {
for ($i = 0, $count = rand(0, 5); $i < $count; $i++) {
$rUser = $users->random();
while ($rUser == $user) {
$rUser = $users->random();
}
$conversation = $user->conversations->intersect($rUser->conversations);
if ($conversation->isEmpty()) {
$conversation = Conversation::create();
$conversation->users()->saveMany([$user, $rUser]);
}
}
}
}