Beispiel #1
0
 /**
  * Rodo skiltį.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Request $request, $slug)
 {
     $sort = $request->input('rodyti');
     $node = Node::where('slug', $slug)->firstOrFail();
     if ($node->parent_node) {
         $topics = $node->topics()->withReplies();
         $expandable = $node->parent_node;
     } else {
         $nodes = Node::where('parent_node', $node->id)->lists('id')->all();
         $topics = Topic::whereIn('node_id', $nodes)->withReplies();
         $expandable = $node->id;
     }
     if ($sort == 'populiariausi' || !$sort) {
         $topics = $topics->pinnedLocal()->popular()->withReplies();
     } else {
         $topics->pinnedLocal()->latest()->withReplies();
     }
     $topics = $topics->paginate(20);
     return view('node.show', compact('node', 'topics', 'sort', 'expandable'));
 }