Esempio n. 1
0
 /**
  * Displays threads belonging to the given forum.
  *
  * @param $id The forum to find threads for
  * @return Response
  */
 public function listThreadsForForum($id)
 {
     // We only care about the ID before the first hyphen
     $id = strtok($id, '-');
     $forum = Forum::where('id', $id)->first();
     $threads = Thread::where('forum', $id)->join('users', 'users.id', '=', 'threads.author')->join('categories', 'categories.id', '=', 'threads.forum')->select('threads.*', 'users.username')->paginate(20);
     return view('forum', compact('threads', 'forum'));
 }
Esempio n. 2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     try {
         App\Thread::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         return redirect('/');
     }
     $this->data['posts'] = App\Thread::findOrFail($id)->posts()->select('posts.*', 'threads.forum_id')->join('threads', 'threads.id', '=', 'posts.thread_id')->paginate(10);
     foreach ($this->data['posts'] as $post) {
         $post->user = App\Post::findOrFail($post->id)->author;
         $post->user->post_count = App\User::findOrFail($post->user->id)->posts()->count();
     }
     $this->data['forum'] = App\Forum::where('id', $this->data['posts'][0]->forum_id)->first();
     $this->data['thread'] = App\Thread::where('id', $id)->first();
     return view('forum.threads.show', $this->data);
 }
 /**
  * Get forum page (a listing of containing threads)
  * @param integer $fid Forum ID
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
  */
 public function getForum($fid)
 {
     $forum = Forum::where('id', $fid)->first();
     if ($forum->type == 0) {
         // Viewing standard forum
         return view('clearboard.pages.forum', ['forum' => $forum]);
     } elseif ($forum->type == 1) {
         // Viewing category
         // @TODO implement viewing of categories
         abort(501);
         // Not Implemented
     } elseif ($forum->type == 2) {
         // Viewing redirect
         $redirect = $forum->meta;
         return redirect($redirect);
     }
 }
Esempio n. 4
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slug)
 {
     // Get the threads for a specific forum and return the view
     // Get the users permissions
     global $canAccess;
     $canAccess = Auth::user()->getPermissions();
     // Get the forum details
     $forum = Forum::where('slug', $slug)->first();
     /*
     $filteredForums = $forums->filter(function ($item) {
         $forum_permission = 'access-forum-'.$item->id;
     
         if(in_array($forum_permission, $GLOBALS['canAccess'])) {
             return $item;
         }
     });
     */
     // Get the threads in the forum
     $threads = Post::with('user')->Topic()->ByForum($forum->id)->orderBy('announcement', 'DESC')->orderBy('sticky', 'DESC')->orderBy('reply_on', 'DESC')->paginate(15);
     return view('forums.threadlist')->withForum($forum)->withThreads($threads);
 }