示例#1
0
 /**
  * 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);
 }
示例#2
0
 /**
  * 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;
 }
示例#3
0
 /**
  * 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);
     });
 }
示例#4
0
 /**
  * Show the 'create topic' view
  *
  * @return \Illuminate\Request
  */
 public function create()
 {
     $board = Board::find($this->request->id);
     return view('topics.create', compact('board'));
 }
示例#5
0
|--------------------------------------------------------------------------
|
| 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']);
示例#6
0
 /**
  *
  */
 public function show($id)
 {
     $board = Board::find($id);
     $topics = Topic::where('board_id', '=', $id)->paginate(15);
     return view('forum.show', compact(['board', 'topics']));
 }