38 lines
923 B
PHP
38 lines
923 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Gallery;
|
|
|
|
use App\Album;
|
|
use App\Facade\Theme;
|
|
use App\Facade\UserConfig;
|
|
use App\Helpers\DbHelper;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class AlbumController extends Controller
|
|
{
|
|
public function index($albumUrlAlias)
|
|
{
|
|
$album = DbHelper::loadAlbumByUrlAlias($albumUrlAlias);
|
|
if (is_null($album))
|
|
{
|
|
App::abort(404);
|
|
return null;
|
|
}
|
|
|
|
$this->authorizeForUser($this->getUser(), 'album.view', $album);
|
|
|
|
$photos = $album->photos()
|
|
->orderBy(DB::raw('COALESCE(taken_at, created_at)'))
|
|
->paginate(UserConfig::get('items_per_page'));
|
|
|
|
return Theme::render('gallery.album', [
|
|
'album' => $album,
|
|
'photos' => $photos
|
|
]);
|
|
}
|
|
}
|