本文整理汇总了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;
}
示例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'));
}
示例3: getLoginWrapper
public function getLoginWrapper()
{
if (!Utils::isNinja() && !User::count()) {
return redirect()->to('invoice_now');
}
return self::getLogin();
}
示例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.');
}
示例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());
}
示例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]);
}
示例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]);
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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();
}
示例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.');
}
示例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;
}