2016-09-04 21:59:32 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Gallery;
|
|
|
|
|
|
|
|
use App\Album;
|
|
|
|
use App\Facade\Theme;
|
2016-09-07 21:44:28 +01:00
|
|
|
use App\Facade\UserConfig;
|
2016-09-09 16:59:13 +01:00
|
|
|
use App\Helpers\DbHelper;
|
2016-09-04 21:59:32 +01:00
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Requests;
|
|
|
|
use Illuminate\Http\Request;
|
2016-09-11 07:19:11 +01:00
|
|
|
use Illuminate\Support\Facades\App;
|
2016-09-08 23:22:29 +01:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2016-09-04 21:59:32 +01:00
|
|
|
|
|
|
|
class AlbumController extends Controller
|
|
|
|
{
|
2016-09-07 21:44:28 +01:00
|
|
|
public function index($albumUrlAlias)
|
2016-09-04 21:59:32 +01:00
|
|
|
{
|
2016-09-09 16:59:13 +01:00
|
|
|
$album = DbHelper::loadAlbumByUrlAlias($albumUrlAlias);
|
|
|
|
if (is_null($album))
|
|
|
|
{
|
|
|
|
App::abort(404);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-09-11 07:19:11 +01:00
|
|
|
$this->authorizeForUser($this->getUser(), 'album.view', $album);
|
2016-09-09 16:59:13 +01:00
|
|
|
|
2016-09-08 23:22:29 +01:00
|
|
|
$photos = $album->photos()
|
|
|
|
->orderBy(DB::raw('COALESCE(taken_at, created_at)'))
|
2016-09-09 17:11:09 +01:00
|
|
|
->paginate(UserConfig::get('items_per_page'));
|
2016-09-04 21:59:32 +01:00
|
|
|
|
|
|
|
return Theme::render('gallery.album', [
|
2016-09-07 21:44:28 +01:00
|
|
|
'album' => $album,
|
|
|
|
'photos' => $photos
|
2016-09-04 21:59:32 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|