示例#1
0
 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');
 }
示例#2
0
文件: EditPost.php 项目: fluxbb/core
 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];
 }
示例#3
0
 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);
 }
示例#4
0
 protected function handleRequest(Request $request)
 {
     $pid = \Route::input('id');
     $this->post = Post::with('author', 'topic')->findOrFail($pid);
     $this->message = $request->input('req_message');
 }