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;
|
|
|
|
|
|
|
|
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-07 21:44:28 +01:00
|
|
|
$photos = $album->photos()->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
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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;
|
|
|
|
}
|
|
|
|
}
|