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


PHP User::count方法代码示例

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


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

示例1: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     echo 'Iniciado' . PHP_EOL;
     $start = microtime(true);
     $totalUsers = User::count();
     //cria o main loop
     $loop = \React\EventLoop\Factory::create();
     //cria a conexão MySQL
     $connection = new \React\MySQL\Connection($loop, array('dbname' => $_ENV['DB_DATABASE'], 'user' => $_ENV['DB_USERNAME'], 'passwd' => $_ENV['DB_PASSWORD']));
     $connection->connect(function () {
     });
     $query1 = '
         SELECT * FROM users
             LEFT JOIN companies ON users.company_id = companies.id
         LIMIT ' . $totalUsers / 2 . '
     ;';
     $query2 = '
         SELECT * FROM users
             LEFT JOIN companies ON users.company_id = companies.id
         LIMIT ' . $totalUsers / 2 . '
         OFFSET ' . $totalUsers / 2 . '
     ;';
     $this->getUsers($connection, $query1, $loop);
     $this->getUsers($connection, $query2, $loop);
     $loop->run();
     echo 'Processados ' . count($this->users) . ' usuários' . PHP_EOL;
     echo 'Demorou ' . number_format((microtime(true) - $start) * 1000, 2, ',', '') . 'ms' . PHP_EOL;
 }
开发者ID:beingsane,项目名称:SeminarioLocaweb,代码行数:33,代码来源:BuildReactCommand.php

示例2: index

 /**
  * Displays the admin welcome page.
  *
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $this->authorize('admin.welcome.index');
     $users = $this->user->count();
     $roles = $this->role->count();
     $permissions = $this->permission->count();
     return view('admin.welcome.index', compact('users', 'roles', 'permissions'));
 }
开发者ID:stevebauman,项目名称:ithub,代码行数:13,代码来源:WelcomeController.php

示例3: getLoginWrapper

 public function getLoginWrapper()
 {
     if (!Utils::isNinja() && !User::count()) {
         return redirect()->to('invoice_now');
     }
     return self::getLogin();
 }
开发者ID:njmube,项目名称:invoice-ninja,代码行数:7,代码来源:AuthController.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param Request $request
  * @param Closure $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     // Retrieve the administrator role.
     $administrator = $this->role->whereName(Role::getAdministratorName())->first();
     // Retrieve the count of users.
     $users = $this->user->count();
     if ($administrator instanceof Role && !$request->user() && $users === 0) {
         // If the administrator role has been created, no user
         // is logged in, and no users exist,
         // we'll allow the setup request.
         return $next($request);
     }
     // If the administrator role hasn't already been created,
     // we'll throw an Unauthorized Exception.
     throw new HttpException(403, 'Unauthorized.');
 }
开发者ID:stevebauman,项目名称:administration,代码行数:24,代码来源:SetupMiddleware.php

示例5: callbackHasNoCode

 public function callbackHasNoCode(FunctionalTester $I)
 {
     $count = User::count() + Profile::count();
     $I->sendGET($this->endpoint . '/facebook/callback');
     $I->seeResponseCodeIs(409);
     $I->seeResponseContainsJson(['status' => 'ERROR', 'message' => 'Ups, something went wrong during authorization']);
     $I->assertEquals($count, User::count() + Profile::count());
 }
开发者ID:soutoner,项目名称:api-desconecta,代码行数:8,代码来源:CallbackCest.php

示例6: index

 public function index()
 {
     $users = User::count();
     $posts = Post::count();
     $categories = Category::count();
     $comments = Comment::count();
     return $this->view('gag/admin/dashboard/index', ['users' => $users, 'posts' => $posts, 'categories' => $categories, 'comments' => $comments]);
 }
开发者ID:spiritwild,项目名称:9gagvn,代码行数:8,代码来源:DashboardController.php

示例7: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //获得数量
     $g = Good::count();
     $o = Order::count();
     $u = User::count();
     $c = Comment::count();
     return view('admin.index.index', ['g' => $g, 'o' => $o, 'u' => $u, 'c' => $c]);
 }
开发者ID:noikiy,项目名称:wfhshop_wechat_laravel,代码行数:14,代码来源:IndexController.php

示例8: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     echo 'Iniciado' . PHP_EOL;
     $start = microtime(true);
     $totalUsers = User::count();
     //Pega todos os usuários do banco, transforma a Collection em Array
     $users = $this->getUsers();
     echo 'Processados ' . count($users) . ' usuários' . PHP_EOL;
     echo 'Demorou ' . number_format((microtime(true) - $start) * 1000, 2, ',', '') . 'ms' . PHP_EOL;
 }
开发者ID:beingsane,项目名称:SeminarioLocaweb,代码行数:15,代码来源:BuildRawCommand.php

示例9: index

 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $routeName = 'dashboard';
     $routeMethod = 'index';
     $users = \App\Models\User::count();
     $sources = \App\Models\Source::count();
     $maps = \App\Models\Map::count();
     $data = compact('routeName', 'routeMethod', 'users', 'sources', 'maps');
     return view('admin.sections.dashboard.index', $data);
 }
开发者ID:jaumesala,项目名称:opendata-maps,代码行数:15,代码来源:DashboardController.php

示例10: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Synchronising user post counts...');
     $this->progress = $this->output->createProgressBar(User::count());
     User::chunk(1000, function ($users) {
         foreach ($users as $u) {
             $u->refreshForumCache();
             $this->progress->advance();
         }
     });
     $this->progress->finish();
 }
开发者ID:Hughp135,项目名称:osu-web,代码行数:17,代码来源:UserForumStatSyncCommand.php

示例11: index

 /**
  * Display a listing of the resource.
  * 
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $data['mem_limit'] = ini_get('memory_limit');
     $data['english_words'] = Word::where('language_id', '1')->count();
     $data['danish_words'] = Word::where('language_id', '2')->count();
     $data['pashto_words'] = Word::where('language_id', '3')->count();
     $data['unique_users'] = User::count();
     $data['users'] = User::limit(4)->get();
     $data['words'] = Word::with(['language', 'user'])->limit(8)->orderBy('created_at', 'desc')->get();
     $used_mem = memory_get_peak_usage(false);
     $data['mem_using'] = round($used_mem / 1024 / 1024, 1) . 'M';
     return view('admin.dashboard', $data);
 }
开发者ID:wayand,项目名称:ps-d-i-c-t-i-o-n-a-r-y,代码行数:18,代码来源:DashboardController.php

示例12: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     echo 'Iniciado' . PHP_EOL;
     $start = microtime(true);
     $totalUsers = User::count();
     $loop = \React\EventLoop\Factory::create();
     $this->getUsers($loop, $totalUsers / 4, 0);
     $this->getUsers($loop, $totalUsers / 4, $totalUsers / 4 * 1);
     $this->getUsers($loop, $totalUsers / 4, $totalUsers / 4 * 2);
     $this->getUsers($loop, $totalUsers / 4, $totalUsers / 4 * 3);
     $loop->run();
     echo 'Processados ' . count($this->users) . ' usuários' . PHP_EOL;
     echo 'Demorou ' . number_format((microtime(true) - $start) * 1000, 2, ',', '') . 'ms' . PHP_EOL;
 }
开发者ID:beingsane,项目名称:SeminarioLocaweb,代码行数:19,代码来源:BuildChildCommand.php

示例13: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     echo 'Iniciando servidor...' . PHP_EOL;
     $totalUsers = User::count();
     $loop = \React\EventLoop\Factory::create();
     $socket = new \React\Socket\Server($loop);
     $socket->on('connection', function ($conn) use($totalUsers) {
         echo 'Enviando mensagem...' . PHP_EOL;
         $users = $this->getUsers($totalUsers / 2, $totalUsers / 2);
         $conn->end(serialize($users));
         echo 'Enviada' . PHP_EOL;
     });
     $socket->listen(1337);
     $loop->run();
 }
开发者ID:beingsane,项目名称:SeminarioLocaweb,代码行数:20,代码来源:SocketServerCommand.php

示例14: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     try {
         DB::connection();
     } catch (Exception $e) {
         $this->error('Unable to connect to database.');
         $this->error('Please fill valid database credentials into .env and rerun this command.');
         return;
     }
     $this->comment('Attempting to install or upgrade Koel.');
     $this->comment('Remember, you can always install/upgrade manually following the guide here:');
     $this->info('📙  https://github.com/phanan/koel/wiki' . PHP_EOL);
     if (!config('app.key')) {
         $this->info('Generating app key');
         Artisan::call('key:generate');
     } else {
         $this->comment('App key exists -- skipping');
     }
     if (!config('jwt.secret')) {
         $this->info('Generating JWT secret');
         Artisan::call('koel:generate-jwt-secret');
     } else {
         $this->comment('JWT secret exists -- skipping');
     }
     $this->info('Migrating database');
     Artisan::call('migrate', ['--force' => true]);
     if (!User::count()) {
         $this->info('Seeding initial data');
         Artisan::call('db:seed', ['--force' => true]);
     } else {
         $this->comment('Data seeded -- skipping');
     }
     $this->info('Executing npm install, gulp and whatnot');
     system('npm install');
     $this->comment(PHP_EOL . '🎆  Success! You can now run Koel from localhost with `php artisan serve`.');
     $this->comment('Again, for more configuration guidance, refer to');
     $this->info('📙  https://github.com/phanan/koel/wiki.');
     $this->comment('WIKI ROCKS WIKI RULES.');
     $this->comment('KTHXBYE.');
 }
开发者ID:phanan,项目名称:koel,代码行数:45,代码来源:Init.php

示例15: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     echo 'Iniciado' . PHP_EOL;
     $start = microtime(true);
     $cacheKey = md5(uniqid(''));
     $totalUsers = User::count();
     $pid = pcntl_fork();
     if ($pid == -1) {
         die('could not fork =(');
     } else {
         if ($pid) {
             // we are the parent
             //É necessário reconectar no banco, os processos vão compartilhar
             //a conexão, o que irá gerar erro
             \DB::reconnect('mysql');
             //Pega os usuários da primeira metade do total
             $users = $this->getUsers($totalUsers / 2, 0);
             //Aguarda o processo filho terminar
             pcntl_wait($status);
             //Faz um merge do que o processo pai e filho processaram
             //Os dados do processo filho estão no cache
             $users = array_merge($users, \Cache::pull($cacheKey));
         } else {
             // we are the child
             //É necessário reconectar no banco, os processos vão compartilhar
             //a conexão, o que irá gerar erro
             \DB::reconnect('mysql');
             //Pega os usuários da segunda metade do total
             $users = $this->getUsers($totalUsers / 2, $totalUsers / 2);
             //Armazena os usuários processados no cache
             \Cache::forever($cacheKey, $users);
             die;
         }
     }
     echo 'Processados ' . count($users) . ' usuários' . PHP_EOL;
     echo 'Demorou ' . number_format((microtime(true) - $start) * 1000, 2, ',', '') . 'ms' . PHP_EOL;
 }
开发者ID:beingsane,项目名称:SeminarioLocaweb,代码行数:42,代码来源:BuildForkCommand.php


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