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-04 21:59:32 +01:00
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Requests;
|
|
|
|
use Illuminate\Http\Request;
|
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
|
|
|
{
|
|
|
|
$album = AlbumController::loadAlbum($albumUrlAlias);
|
2016-09-08 23:22:29 +01:00
|
|
|
$photos = $album->photos()
|
|
|
|
->orderBy(DB::raw('COALESCE(taken_at, created_at)'))
|
|
|
|
->paginate(UserConfig::get('items_per_page_admin'));
|
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
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $id
|
|
|
|
* @return Album
|
|
|
|
*/
|
|
|
|
private static function loadAlbum($urlAlias)
|
|
|
|
{
|
|
|
|
$album = Album::where('url_alias', $urlAlias)->first();
|
|
|
|
if (is_null($album))
|
|
|
|
{
|
|
|
|
App::abort(404);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $album;
|
|
|
|
}
|
|
|
|
}
|