本文整理汇总了PHP中app\Board::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Board::count方法的具体用法?PHP Board::count怎么用?PHP Board::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Board
的用法示例。
在下文中一共展示了Board::count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boardStats
/**
* Returns the information specified by boardStats
*
* @return array (indexes and vales based on $boardStats)
*/
protected function boardStats()
{
$controller =& $this;
$stats = Cache::remember('index.boardstats', 60, function () use($controller) {
$stats = [];
foreach ($controller->boardStats as $boardStat) {
switch ($boardStat) {
case "boardCount":
$stats[$boardStat] = Board::whereIndexed()->count();
break;
case "boardIndexedCount":
$stats[$boardStat] = Board::count();
break;
case "postCount":
$stats[$boardStat] = Board::sum('posts_total');
break;
case "postRecentCount":
$stats[$boardStat] = Post::recent()->count();
break;
}
}
return $stats;
});
return $stats;
}
示例2: boardStats
/**
* Returns the information specified by boardStats
*
* @return array (indexes and vales based on $boardStats)
*/
protected function boardStats()
{
$controller =& $this;
$stats = Cache::remember('index.boardstats', 60, function () use($controller) {
$stats = [];
foreach ($controller->boardStats as $boardStat) {
switch ($boardStat) {
case "boardIndexedCount":
$stats[$boardStat] = Board::whereIndexed()->count();
break;
case "startDate":
$stats[$boardStat] = Board::orderBy('created_at', 'desc')->take(1)->pluck('created_at')->format("M jS, Y");
break;
case "boardTotalCount":
$stats[$boardStat] = Board::count();
break;
case "postCount":
$stats[$boardStat] = Board::sum('posts_total');
break;
case "postRecentCount":
$stats[$boardStat] = Post::recent()->count();
break;
}
}
return $stats;
});
return $stats;
}
示例3: run
public function run()
{
$this->command->info("Seeding boards.");
if (Board::count() < 1) {
$board = Board::firstOrCreate(['board_uri' => "test", 'title' => "Test", 'description' => "Discover software features on your own", 'created_by' => 1, 'operated_by' => 1]);
$this->command->info("Success. Board exists now. Accessible at /test/.");
} else {
$this->command->info("Skipped. Site has a board.");
}
}
示例4: testModelAndViews
/**
* Tests the board model and depndant views.
*
* @return void
*/
public function testModelAndViews()
{
// Get a board.
$boards = Board::take(1)->get();
// Get a board that cannot exist.
// The maximum `board_uri` length should be, at most, 31.
$noBoards = Board::where('board_uri', "12345678901234567890123456789012")->take(1)->get();
$this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Collection", $boards);
$this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Collection", $noBoards);
$this->assertEquals(0, count($noBoards));
if (count($boards)) {
$this->board = $board = $boards[0];
$this->assertInstanceOf("App\\Board", $board);
// Test relationships
$this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Relations\\HasMany", $board->posts());
$this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Relations\\HasMany", $board->logs());
$this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Relations\\HasMany", $board->threads());
$this->assertInstanceOf("Illuminate\\Database\\Eloquent\\Relations\\HasMany", $board->roles());
// Test modern routes
$response = $this->call('GET', url("{$board->board_uri}"));
$this->assertEquals(200, $response->getStatusCode());
$this->doBoardIndexAssertions();
$response = $this->call('GET', url("{$board->board_uri}/1"));
$this->assertEquals(200, $response->getStatusCode());
$this->doBoardIndexAssertions();
$response = $this->call('GET', url("{$board->board_uri}/catalog"));
$this->assertEquals(200, $response->getStatusCode());
$response = $this->call('GET', url("{$board->board_uri}/logs"));
$this->assertEquals(200, $response->getStatusCode());
$this->assertViewHas('board');
$this->assertViewHas('logs');
// Test legacy routes
$legacyCode = env('LEGACY_ROUTES', false) ? 302 : 404;
$response = $this->call('GET', url("{$board->board_uri}/index.html"));
$this->assertEquals($legacyCode, $response->getStatusCode());
$response = $this->call('GET', url("{$board->board_uri}/1.html"));
$this->assertEquals($legacyCode, $response->getStatusCode());
$response = $this->call('GET', url("{$board->board_uri}/catalog.html"));
$this->assertEquals($legacyCode, $response->getStatusCode());
} else {
$this->assertEquals(0, Board::count());
}
}