Ejemplo n.º 1
0
 public function show($groupName)
 {
     $group = Group::name($groupName)->with('creator')->firstOrFail();
     $group->checkAccess();
     $stats = ['contents' => intval(Content::where('group_id', $group->getKey())->count()), 'comments' => intval(Content::where('group_id', $group->getKey())->sum('comments')), 'entries' => intval(Entry::where('group_id', $group->getKey())->count()), 'banned' => intval(GroupBan::where('group_id', $group->getKey())->count()), 'subscribers' => $group->subscribers, 'moderators' => intval(GroupModerator::where('group_id', $group->getKey())->count())];
     return array_merge($group->toArray(), ['stats' => $stats]);
 }
Ejemplo n.º 2
0
 public function search()
 {
     if (Input::has('q')) {
         $keywords = preg_replace('/((\\w+):(\\w+\\pL.))+\\s?/i', '', Input::get('q'));
         switch (Input::get('t')) {
             case 'e':
                 $builder = Entry::where('text', 'like', '%' . $keywords . '%');
                 break;
             case 'g':
                 $builder = Group::where('name', 'like', '%' . $keywords . '%')->orWhere('urlname', 'like', '%' . $keywords . '%');
                 break;
             case 'c':
             default:
                 $builder = Content::where(function ($query) use($keywords) {
                     $query->where('title', 'like', '%' . $keywords . '%')->orWhere('description', 'like', '%' . $keywords . '%');
                 });
                 break;
         }
         $this->builder = $builder;
         $this->setupFilters(Input::get('q'));
         $results = $this->builder->paginate(25);
     }
     return view('search.main', compact('results'));
 }