url_alias = ucfirst(preg_replace('/[^a-z0-9\-]/', '-', strtolower($this->name))); } /** * @return IAlbumSource */ public function getAlbumSource() { // TODO allow albums to specify different storage locations - e.g. Amazon S3, SFTP/FTP, OpenStack return new LocalFilesystemSource($this, dirname(__DIR__) . '/storage/app/albums'); } public function photos() { return $this->hasMany(Photo::class); } public function thumbnailUrl($thumbnailName) { $photo = $this->photos() ->inRandomOrder() ->first(); if (!is_null($photo)) { return $this->getAlbumSource()->getUrlToPhoto($photo, $thumbnailName); } return ''; } public function url() { return route('viewAlbum', $this->url_alias); } }