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


PHP Board::where方法代码示例

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


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

示例1: 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());
     }
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:48,代码来源:BoardTest.php

示例2: getBoardsWithConfigRights

 /**
  * Returns a list of board_uris where the canEditConfig permission is given.
  *
  * @return Collection  of Board
  */
 public function getBoardsWithConfigRights()
 {
     $whitelist = true;
     $boardlist = [];
     if ($this->canEditConfig(null)) {
         $whitelist = false;
     }
     foreach ($this->getPermissions() as $board_uri => $permission) {
         if ($this->canEditConfig($board_uri) === $whitelist) {
             $boardlist[] = $board_uri;
         }
     }
     $boardlist = array_unique($boardlist);
     return Board::where(function ($query) use($whitelist, $boardlist) {
         if ($whitelist) {
             $query->whereIn('board_uri', $boardlist);
         } else {
             $query->whereNotIn('board_uri', $boardlist);
         }
     })->andCreator()->andOperator()->andStaffAssignments()->get();
 }
开发者ID:Cipherwraith,项目名称:infinity-next,代码行数:26,代码来源:PermissionUser.php

示例3: importInfinityAttachments

 /**
  * Imports board attachments.
  *
  * @return void
  */
 public function importInfinityAttachments()
 {
     $this->info("\tImporting attachments ...");
     Board::where('board_uri', '>=', "jonimu")->orderBy('board_uri', 'asc')->chunk(1, function ($boards) {
         foreach ($boards as $board) {
             FileAttachment::whereForBoard($board)->forceDelete();
             $this->line("\t\tImporting attachments from /{$board->board_uri}/");
             $tTable = $this->tcon->table("posts_{$board->board_uri}");
             $storageLinked = 0;
             $attachmentsMade = 0;
             // Threads first, replies by id.
             $tTable->where('num_files', '>', 0)->orderByRaw('thread asc, id asc')->chunk(200, function ($posts) use(&$board, &$attachmentsMade, &$storageLinked) {
                 $this->line("\t\t\tImporting 200 more posts's attachments ...");
                 $aModels = [];
                 $fModels = [];
                 $skips = 0;
                 // [{
                 // 	"name":"1417727856564.png",
                 // 	"type":"image\/png",
                 // 	"tmp_name":"\/tmp\/php05oN25",
                 // 	"error":0,
                 // 	"size":13034,
                 // 	"filename":"1417727856564.png",
                 // 	"extension":"png",
                 // 	"file_id":"1423141860833",
                 // 	"file":"1423141860833.png",
                 // 	"thumb":"1423141860833.jpg",
                 // 	"is_an_image":true,
                 // 	"hash":"8c63f0b812657c38966ddc7d387a9a4b",
                 // 	"width":223,
                 // 	"height":200,
                 // 	"thumbwidth":223,
                 // 	"thumbheight":200,
                 // 	"file_path":"b\/src\/1423141860833.png",
                 // 	"thumb_path":"b\/thumb\/1423141860833.jpg"
                 // }]
                 // files, num_files, filehash
                 foreach ($posts as $post) {
                 }
                 if (FileAttachment::insert($aModels)) {
                     $attachmentsMade += count($aModels);
                 }
             });
             $this->line("\t\t\tImported {$storageLinked} files with {$attachmentsMade} attachments.");
         }
     });
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:52,代码来源:Import.php

示例4: getNavigationPrimaryBoards

 /**
  * Returns the primary navigation board list.
  *
  * @return array|false  Returns false if the setting boardListShow is disabled.
  */
 public function getNavigationPrimaryBoards()
 {
     if ($this->hasDB() && $this->get('boardListShow', false)) {
         return Cache::remember('site.gnav.boards', 1, function () {
             $popularBoards = Board::where('posts_total', '>', 0)->wherePublic()->select('board_uri', 'title')->orderBy('posts_total', 'desc')->take(20)->get();
             $recentBoards = Board::where('posts_total', '>', 0)->wherePublic()->whereNotIn('board_uri', $popularBoards->pluck('board_uri'))->select('board_uri', 'title')->orderBy('last_post_at', 'desc')->take(20)->get();
             return ['popular_boards' => $popularBoards, 'recent_boards' => $recentBoards];
         });
     }
     return false;
 }
开发者ID:JEWSbreaking8chan,项目名称:infinity-next,代码行数:16,代码来源:SettingManager.php

示例5: getBoardsWithConfigRights

 /**
  * Returns a list of board_uris where the canEditConfig permission is given.
  *
  * @return Collection  of Board
  */
 public function getBoardsWithConfigRights()
 {
     $whitelist = true;
     $boardlist = [];
     if ($this->canEditConfig(null)) {
         $whitelist = false;
     }
     $boardlist = $this->canInBoards('board.config');
     $boardlist = array_unique($boardlist);
     if (empty($boardlist)) {
         return collect();
     }
     return Board::where(function ($query) use($whitelist, $boardlist) {
         if ($whitelist && !in_array(null, $boardlist)) {
             $query->whereIn('board_uri', $boardlist);
         }
     })->andAssets()->andCreator()->andOperator()->andStaffAssignments()->paginate(25);
 }
开发者ID:tmrwbo,项目名称:infinity-next,代码行数:23,代码来源:PermissionUser.php

示例6: getNavigationPrimaryBoards

 /**
  * Returns the primary navigation board list.
  *
  * @return array|false  Returns false if the setting boardListShow is disabled.
  */
 public function getNavigationPrimaryBoards()
 {
     if ($this->hasDB() && $this->get('boardListShow', false)) {
         if (Cache::has("site.boardlist")) {
             return Cache::remember('site.gnav.boards', 1, function () {
                 $popularBoards = collect();
                 $recentBoards = collect();
                 $popularBoardArray = Board::getBoardsForBoardlist(0, 20);
                 foreach ($popularBoardArray as $popularBoard) {
                     $popularBoards->push(new Board($popularBoard));
                 }
                 $recentBoards = Board::where('posts_total', '>', 0)->whereNotNull('last_post_at')->wherePublic()->whereNotIn('board_uri', $popularBoards->pluck('board_uri'))->select('board_uri', 'title')->orderBy('last_post_at', 'desc')->take(20)->get();
                 return ['popular_boards' => $popularBoards, 'recent_boards' => $recentBoards];
             });
         }
         return ['popular_boards' => collect(), 'recent_boards' => collect()];
     }
     return false;
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:24,代码来源:SettingManager.php


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