示例#1
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);
 }