当前位置: 首页>>代码示例>>PHP>>正文


PHP User::count方法代码示例

本文整理汇总了PHP中App\Model\User::count方法的典型用法代码示例。如果您正苦于以下问题:PHP User::count方法的具体用法?PHP User::count怎么用?PHP User::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App\Model\User的用法示例。


在下文中一共展示了User::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     //总访问量
     $visits = \Cache::get('visits', 0);
     //今日注册用户
     $todayUsers = User::today()->count('user_id');
     //总用户数
     $totalUsers = User::count('user_id');
     //管理员聊天记录
     $chatMessages = AdminMessage::with('admin')->limit(10)->oldest()->get();
     //最新留言
     $guestBook = GuestBook::with('user')->limit(10)->oldest()->get();
     //最新注册用户
     $users = User::limit(24)->oldest()->get();
     //最新评论
     $comments = Comment::limit(10)->oldest()->get();
     // 总会员数量/待审核会员/普通会员/高端会员
     $user_all_num = User::count('user_id');
     $user_shenhe_num = User::status(\App\Enum\User::STATUS_CHECK)->count('user_id');
     $user_level1_num = User::level(\App\Enum\User::LEVEL_1)->count('user_id');
     $user_level3_num = User::level(\App\Enum\User::LEVEL_3)->count('user_id');
     // 自我介绍待审核数量
     $user_info_num = UserInfo::where('introduce_status', \App\Enum\User::INTRODUCE_CHECK)->count('user_id');
     // 会员相片审核数量
     $user_gallery_num = DB::table('user_gallery')->where('status', '待审核')->where('image_url', '!=', '')->count('photo_id');
     // 文章数量
     $article_num = DB::table('articles')->count('article_id');
     $res = array('user_all_num' => $user_all_num, 'user_shenhe_num' => $user_shenhe_num, 'user_level1_num' => $user_level1_num, 'user_level3_num' => $user_level3_num, 'user_info_num' => $user_info_num, 'user_gallery_num' => $user_gallery_num, 'article_num' => $article_num);
     return $this->view('index', $res);
     // return $this->view('index')->with('visits', $visits)->with('todayUsers', $todayUsers)->with('totalUsers',
     //         $totalUsers)->with('chatMessages', $chatMessages)->with('guestBook', $guestBook)->with('users',
     //         $users)->with('comments', $comments);
 }
开发者ID:netxinyi,项目名称:meigui,代码行数:33,代码来源:HomeController.php

示例2: home

 public function home()
 {
     $this->view->title = $this->view->site_name;
     $this->view->asset_count = Asset::count();
     $this->view->user_count = User::count();
     $this->view->crew_count = Crew::count();
     $this->view->job_list_count = JobList::count();
     $this->view->job_count = Job::count();
     $this->view->tag_count = Tag::count();
     return $this->view;
 }
开发者ID:samwilson,项目名称:asset-manager,代码行数:11,代码来源:DashboardController.php

示例3: createOrFindUser

 /**
  * @param \Laravel\Socialite\Contracts\User $login
  * @return User
  */
 private function createOrFindUser($login)
 {
     $user = User::firstOrNew(['email' => $login->getEmail()]);
     if ($user->exists) {
         return $user;
     }
     $user->name = $login->getName() ?: $login->getNickname();
     $user->nickname = $login->getNickname();
     $user->password = Hash::make($login->getId() . time());
     $user->avatar = $login->getAvatar();
     $user->admin = User::count() == 0;
     $user->save();
     return $user;
 }
开发者ID:dzirg44,项目名称:dogpro,代码行数:18,代码来源:AuthController.php

示例4: authenticate

 public function authenticate($identity)
 {
     return \App\Model\User::count(['conditions' => 'id = :id:', 'bind' => ['id' => (int) $identity]]) > 0;
 }
开发者ID:redound,项目名称:phalcon-rest-boilerplate,代码行数:4,代码来源:EmailAccountType.php

示例5: users

 protected function users()
 {
     if (!Schema::hasTable('users')) {
         $this->info("Creating 'users' table.");
         Schema::create('users', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name')->nullable();
             $table->string('username')->unique();
             $table->string('email')->nullable();
             $table->string('password', 60);
             $table->string('password_reminder', 100)->nullable();
             $table->rememberToken();
             $table->timestamps();
         });
     }
     if (User::count() == 0) {
         $this->info("No users found; creating 'admin'.");
         $adminUser = new User();
         $adminUser->username = 'admin';
         $adminUser->name = 'Administrator';
         $adminUser->password = bcrypt('admin');
         $adminUser->email = config('app.site_email');
         $adminUser->save();
     }
     if (!Schema::hasTable('roles')) {
         $this->info("Creating 'roles' table.");
         Schema::create('roles', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name')->unique();
             $table->timestamps();
         });
     }
     if (!Role::find(Role::ADMIN)) {
         $this->info("Creating admin role.");
         Role::firstOrCreate(['id' => Role::ADMIN, 'name' => trans_choice('roles.admin', 1)]);
     }
     $managerRole = Role::find(Role::MANAGER);
     if (!$managerRole) {
         $this->info("Creating manager role.");
         Role::firstOrCreate(['id' => Role::MANAGER, 'name' => trans_choice('roles.manager', 1)]);
     }
     $clerkRole = Role::find(Role::CLERK);
     if (!$clerkRole) {
         $this->info("Creating clerk role.");
         Role::firstOrCreate(['id' => Role::CLERK, 'name' => trans_choice('roles.clerk', 1)]);
     }
     if (!Schema::hasTable('role_user')) {
         $this->info("Creating 'role_user' table.");
         Schema::create('role_user', function (Blueprint $table) {
             $table->integer('user_id')->unsigned();
             $table->foreign('user_id')->references('id')->on('users');
             $table->integer('role_id')->unsigned();
             $table->foreign('role_id')->references('id')->on('roles');
             $table->primary(['user_id', 'role_id']);
         });
     }
     // If there are no administrators, make the first user an admin.
     $adminRole = Role::find(Role::ADMIN);
     if (count(User::administrators()) === 0) {
         $adminUser = User::first();
         $this->info("Making " . $adminUser->name . " an Administrator.");
         $adminUser->roles()->save($adminRole);
     }
     if (!Schema::hasTable('unavailability_types')) {
         $this->info("Creating 'unavailability_types' table.");
         Schema::create('unavailability_types', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name')->unique();
             $table->string('background_colour');
             $table->string('colour');
         });
     }
     if (!Schema::hasTable('user_unavailabilities')) {
         $this->info("Creating 'user_unavailabilities' table.");
         Schema::create('user_unavailabilities', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id')->unsigned()->nullable();
             $table->foreign('user_id')->references('id')->on('users');
             $table->date('start_date')->nullable();
             $table->date('end_date')->nullable();
             $table->integer('type_id')->unsigned()->nullable();
             $table->foreign('type_id')->references('id')->on('unavailability_types');
             $table->timestamps();
         });
     }
     if (!Schema::hasTable('queued_emails')) {
         $this->info("Creating 'queued_emails' table.");
         Schema::create('queued_emails', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('recipient_id')->unsigned()->nullable();
             $table->foreign('recipient_id')->references('id')->on('users');
             $table->string('subject');
             $table->string('template');
             $table->text('data');
             $table->timestamps();
         });
     }
 }
开发者ID:samwilson,项目名称:asset-manager,代码行数:98,代码来源:Upgrade.php


注:本文中的App\Model\User::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。