private function extractGroupPost($data)
 {
     if (is_array($data)) {
         list($postId, $areaSlug, $categorySlug) = $data;
         if ($post = Post::find($postId, ['title', 'user_id'])) {
         }
         return compact('post', 'areaSlug', 'categorySlug');
     }
     return null;
 }
 public function store($pageId, $pageType)
 {
     if (in_array($pageType, ['group'])) {
         if (!$this->user()) {
             return abort(404);
         }
         if (!$this->user()->can('edit_comments')) {
             $post = Post::findOrFail($pageId);
             if ($this->user()->isTrainer()) {
                 $groups = $this->user()->trainerGroups();
             } else {
                 $groups = $this->user()->groups();
             }
             if (!in_array($post->area_group_id, $groups->lists('id'))) {
                 return abort(404);
             }
         }
     }
     $input = Input::only('author_name', 'author_email', 'content', 'g-recaptcha-response');
     $input['parent_id'] = Input::get('parent_id', 0);
     $input['page_id'] = $pageId;
     $input['page_type'] = $pageType;
     $input['author_ip'] = Request::ip();
     $input['county_id'] = config('app.county');
     if ($this->user()) {
         $input['user_id'] = $this->user()->id;
     }
     $this->commentForm->validate($input);
     unset($input['g-recaptcha-response']);
     $comment = Comments::addComment($input);
     if (!$comment instanceof Comment) {
         return json(is_object($comment) ? $comment->first() : trans('errors.save'));
     }
     if (!$this->user()) {
         $name = cookie('author_name', e($input['author_name']), 99999);
         $email = cookie('author_email', e($input['author_email']), 99999);
         return json($comment->toArray(false))->withCookie($name)->withCookie($email);
     }
     return json($comment->toArray(false));
 }
 private function query()
 {
     if ($this->user()->can('add_areas')) {
         return Post::query();
     }
     return Post::where('user_id', $this->user()->id);
 }
 private function show($area, $category, $postId)
 {
     $post = Post::findOrFail($postId);
     return view('area.article', compact('area', 'category', 'post'));
 }