protected function handleRequest(Request $request) { $pid = \Route::input('id'); // Fetch some info about the topic $topic = Post::with('author', 'topic')->findOrFail($pid); $this->data['post'] = $post; $this->data['action'] = trans('fluxbb::forum.edit_post'); }
protected function run() { $pid = $this->get('id'); $post = Post::with('author', 'topic')->findOrFail($pid); $creator = User::current(); $post->fill(['message' => $this->get('message'), 'edited' => Carbon::now(), 'edited_by' => $creator->username]); $post->save(); $this->raise(new PostWasEdited($post, $creator)); return ['post' => $post]; }
public function get_topic($tid, $page = 1) { // Fetch some info about the topic $topic = Topic::with(array('forum', 'forum.perms'))->where('id', '=', $tid)->whereNull('moved_to')->first(); if ($topic === NULL) { return \Event::first('404'); } $disp_posts = $this->user()->dispPosts(); $num_pages = ceil(($topic->num_replies + 1) / $disp_posts); $page = $page <= 1 || $page > $num_pages ? 1 : intval($page); $start_from = $disp_posts * ($page - 1); // TODO: Use paginate? // Fetch post data // TODO: Can we enforce the INNER JOIN here somehow? $posts = Post::with(array('poster', 'poster.group'))->where('topic_id', '=', $tid)->orderBy('id')->skip($start_from)->take($disp_posts)->get(); // TODO: Or do I need to fetch the IDs here first, since those big results will otherwise have to be filtered after fetching by LIMIT / OFFSET? return \View::make('fluxbb::viewtopic')->with('topic', $topic)->with('posts', $posts)->with('start_from', $start_from); }
protected function handleRequest(Request $request) { $pid = \Route::input('id'); $this->post = Post::with('author', 'topic')->findOrFail($pid); $this->message = $request->input('req_message'); }