/** * Shows a forum * * @param int $id The ID of the forum * @return void */ public function show($id) { $forum = Forum::with(array('threads' => function ($query) { $query->orderBy('sticky', 'desc')->orderBy('updated_at', 'desc'); }))->isAccessible()->findOrFail($id); $this->pageView('forums::show_forum', compact('forum')); }
public function update($id) { $forum = Forum::findOrFail($id); $oldParentId = $forum->forum_id; $response = $this->traitUpdate($id); $forum = Forum::findOrFail($id); /* * If the forum's parent forum changed we have to refresh * the old and the new parent forum's meta infos */ if ($forum->forum_id != $oldParentId) { $oldParentForum = Forum::find($oldParentId); $oldParentForum->refresh(); $forum->forum->refresh(); } return $response; }
/** * Moves a thread * * @param int $id The ID of the thread */ public function postMove($id) { if (!($this->hasAccessUpdate() or $forumPost->creator_id == user()->id)) { return $this->alertError(trans('app.access_denied')); } $forumThread = ForumThread::isAccessible()->findOrFail($id); $oldForum = $forumThread->forum; $forumThread->fill(Input::all()); $forumThread->save(); // save() not forceSave() so it checks if the parent forum is valid $newForum = Forum::whereId($forumThread->forum_id)->firstOrFail(); // We cant simply access $forumThread->forum! $newForum->refresh(); $oldForum->refresh(); $this->alertFlash(trans('app.updated', ['Thread'])); return Redirect::to('forums/' . $forumThread->forum_id); }
public function edit($id) { $this->traitEdit($id); $forums = Forum::where('id', '!=', $id)->get(); $this->layout->page->with('forums', $forums); }