Exemplo n.º 1
0
 /**
  * @return mixed
  */
 public function index()
 {
     if (Input::has('folder')) {
         $username = request('user', auth()->id());
         $entity = $this->folders->getByName($username, request('folder'));
     } else {
         $groupName = request('group', 'all');
         $entity = $this->groups->requireByName($groupName);
     }
     $type = request('type', 'all');
     $canSortBy = ['comments', 'uv', 'created_at', 'frontpage_at'];
     $orderBy = in_array(request('sort'), $canSortBy) ? request('sort') : null;
     $builder = $entity->contents($type, $orderBy)->with('group', 'user');
     // Time filter
     $time = request('time');
     if ($time) {
         $builder->fromDaysAgo($time);
     }
     // Domain filter
     $domain = request('domain');
     if ($domain) {
         $builder->where('domain', $domain);
     }
     // User filter
     if (Input::has('user')) {
         $user = User::name(request('user'))->firstOrFail();
         $builder->where('user_id', $user->getKey());
     }
     $perPage = Input::has('per_page') ? between(request('per_page'), 1, 100) : 20;
     return $builder->paginate($perPage);
 }
Exemplo n.º 2
0
 public function showEntriesFromFolder()
 {
     $userName = Route::input('user') ?: Auth::id();
     $folderName = Route::input('folder');
     $folder = $this->folders->getByName($userName, $folderName);
     view()->share('folder', $folder);
     $builder = $folder->entries();
     return $this->showEntries($builder);
 }
Exemplo n.º 3
0
 /**
  * Display contents from given folder.
  *
  * @return \Illuminate\View\View|\Symfony\Component\HttpFoundation\Response
  */
 public function showContentsFromFolder()
 {
     $tab = str_contains(Route::currentRouteName(), 'new') ? 'new' : 'popular';
     $userName = Route::input('user') ?: Auth::id();
     $folderName = Route::input('folder');
     $folder = $this->folders->requireByName($userName, $folderName);
     view()->share('folder', $folder);
     if (!$folder->canBrowse()) {
         abort(404);
     }
     $canSortBy = ['comments', 'uv', 'created_at', 'frontpage_at'];
     $orderBy = in_array(request('sort'), $canSortBy) ? request('sort') : null;
     $builder = $folder->contents($tab, $orderBy);
     return $this->showContents($builder);
 }
Exemplo n.º 4
0
 public function index()
 {
     if (Input::has('folder')) {
         $username = request('user', auth()->id());
         $entity = $this->folders->getByName($username, request('folder'));
     } else {
         $groupName = request('group', 'all');
         $entity = $this->groups->getByName($groupName);
     }
     $sortBy = in_array(request('sort'), ['uv', 'created_at']) ? request('sort') : 'created_at';
     $builder = $entity->comments($sortBy)->with(['user', 'group', 'replies', 'replies.user']);
     // Time filter
     if (Input::has('time')) {
         $builder->fromDaysAgo(request('time'));
     }
     $perPage = Input::has('per_page') ? between(request('per_page'), 1, 100) : 20;
     return $builder->paginate($perPage);
 }