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


PHP Board::find方法代码示例

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


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

示例1: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $board = Board::find($id);
     if (!$board) {
         return \Response::json(['error' => ['message' => 'Board does not exist']], 404);
     }
     return \Response::json(['data' => $board->toArray()], 200);
 }
开发者ID:kylerdanielster,项目名称:Mello,代码行数:14,代码来源:BoardController.php

示例2: getForThreadView

 /**
  * Returns a thread with its replies for a thread view and leverages cache.
  *
  * @static
  * @param  string  $board_uri  Board primary key.
  * @param  int     $board_id   Local board id.
  * @param  string  $uri        Optional. URI string for splicing the thread. Defaults to null, for no splicing.
  * @return static
  */
 public static function getForThreadView($board_uri, $board_id, $uri = null)
 {
     // Prepare the board so that we do not have to make redundant searches.
     $board = null;
     if ($board_uri instanceof Board) {
         $board = $board_uri;
         $board_uri = $board->board_uri;
     } else {
         $board = Board::find($board_uri);
     }
     // Prep the
     $rememberTags = ["board.{$board_uri}", "threads"];
     $rememberTimer = 30;
     $rememberKey = "board.{$board_uri}.thread.{$board_id}";
     $rememberClosure = function () use($board, $board_uri, $board_id) {
         $thread = static::where(['posts.board_uri' => $board_uri, 'posts.board_id' => $board_id])->withEverythingAndReplies()->first();
         if ($thread) {
             $thread->prepareForCache();
         }
         return $thread;
     };
     switch (env('CACHE_DRIVER')) {
         case "file":
         case "database":
             $thread = Cache::remember($rememberKey, $rememberTimer, $rememberClosure);
             break;
         default:
             $thread = Cache::tags($rememberTags)->remember($rememberKey, $rememberTimer, $rememberClosure);
             break;
     }
     if (!is_null($uri)) {
         return $thread->getReplySplice($uri);
     }
     return $thread;
 }
开发者ID:RustyGamer,项目名称:infinity-next,代码行数:44,代码来源:Post.php

示例3: importInfinityBoardTags

 /**
  * Imports board tags.
  *
  * @return void
  */
 public function importInfinityBoardTags()
 {
     # THEIR TABLES
     $tTagsTable = $this->tcon->table("board_tags");
     # BEGIN USER IMPORT
     $this->info("\tImporting Tags ...");
     $tTagsTable->chunk(100, function ($tags) {
         $this->line("\t\tImporting 100 tags.");
         $boardTags = [];
         $tagModels = [];
         foreach ($tags as $tag) {
             $tagTxt = substr((string) $tag->tag, 0, 32);
             if (!isset($boardTags[$tag->uri])) {
                 $boardTags[$tag->uri] = [];
             }
             if (!isset($tagModels[$tagTxt])) {
                 $tagModels[$tagTxt] = BoardTag::firstOrCreate(['tag' => $tagTxt]);
             }
             $boardTags[$tag->uri] = $tagModels[$tagTxt];
         }
         foreach ($boardTags as $board_uri => $tags) {
             $board = Board::find($board_uri);
             if ($board) {
                 $board->tags()->attach($tags);
             } else {
                 $this->warn("\t\t\tBoard \"{$board_uri}\" could not be found to add tags to.");
             }
         }
         unset($tag, $tagModel, $tagModels, $boardTags);
     });
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:36,代码来源:Import.php

示例4: create

 /**
  * Show the 'create topic' view
  *
  * @return \Illuminate\Request
  */
 public function create()
 {
     $board = Board::find($this->request->id);
     return view('topics.create', compact('board'));
 }
开发者ID:larabb,项目名称:larabb,代码行数:10,代码来源:TopicsController.php

示例5: function

|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::group(['prefix' => '/'], function () {
    /*
    | Index route
    */
    Route::get('/', 'WelcomeController@getIndex');
    Route::controller('boards.html', 'BoardlistController');
    Route::get('overboard.html', 'MultiboardController@getOverboard');
    Route::get('query.test', function () {
        \App\Board::find('b')->getThreadsForIndex(0);
        return "Hello.";
    });
    /*
    | Control Panel (cp)
    | Anything having to deal with secure information goes here.
    | This includes:
    | - Registration, Login, and Account Recovery.
    | - Contributor status.
    | - Board creation, Board management, Volunteer management.
    | - Top level site management.
    */
    Route::group(['namespace' => 'Panel', 'middleware' => 'App\\Http\\Middleware\\VerifyCsrfToken', 'prefix' => 'cp'], function () {
        // Simple /cp/ requests go directly to /cp/home
        Route::get('/', 'HomeController@getIndex');
        Route::controllers(['auth' => 'AuthController', 'home' => 'HomeController', 'password' => 'PasswordController']);
开发者ID:RustyGamer,项目名称:infinity-next,代码行数:31,代码来源:routes.php

示例6: show

 /**
  *
  */
 public function show($id)
 {
     $board = Board::find($id);
     $topics = Topic::where('board_id', '=', $id)->paginate(15);
     return view('forum.show', compact(['board', 'topics']));
 }
开发者ID:larabb,项目名称:larabb,代码行数:9,代码来源:BoardsController.php


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