Пример #1
0
 /**
  * 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
0
 /**
  * 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
0
 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
0
 /**
  * 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());
     }
 }