Beispiel #1
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     $parser = new \cebe\markdown\GithubMarkdown();
     $query = \Request::query();
     try {
         if (array_key_exists('read', $query)) {
             $this->isNtyChecked($query['nty']);
         }
         $snippet = $this->snippet->findOrFail($id);
         $comments = Comment::commentList($id);
         $stocksAndComments = $this->snippet->stocksAndCommentsCount($id);
         $popularSnippets = User::getMyPopularSnippets($snippet['user_id']);
         $parsedComment = array_map(function ($comment) use($parser) {
             $comment->parsedComment = $parser->parse($comment->comment);
             return $comment;
         }, $comments);
         $markdown = $parser->parse($snippet->body);
         $snippet['body'] = $markdown;
         return view('snippet.show')->with(compact('snippet', 'parsedComment', 'stocksAndComments', 'popularSnippets'));
     } catch (ModelNotFoundException $e) {
         return \Response::view('errors.404', [], '404');
     }
 }