コード例 #1
0
ファイル: AlbumsController.php プロジェクト: nsystem1/Pony.fm
 public function getDownload($id, $extension)
 {
     $album = Album::with('tracks', 'user')->find($id);
     if (!$album) {
         App::abort(404);
     }
     $format = null;
     $formatName = null;
     foreach (Track::$Formats as $name => $item) {
         if ($item['extension'] == $extension) {
             $format = $item;
             $formatName = $name;
             break;
         }
     }
     if ($format == null) {
         App::abort(404);
     }
     ResourceLogItem::logItem('album', $id, ResourceLogItem::DOWNLOAD, $format['index']);
     $downloader = new AlbumDownloader($album, $formatName);
     $downloader->download();
 }
コード例 #2
0
ファイル: AlbumsController.php プロジェクト: nsystem1/Pony.fm
 public function getEdit($id)
 {
     $album = Album::with('tracks')->find($id);
     if (!$album) {
         return $this->notFound('Album ' . $id . ' not found!');
     }
     if ($album->user_id != Auth::user()->id) {
         return $this->notAuthorized();
     }
     $tracks = [];
     foreach ($album->tracks as $track) {
         $tracks[] = ['id' => $track->id, 'title' => $track->title];
     }
     return Response::json(['id' => $album->id, 'title' => $album->title, 'user_id' => $album->user_id, 'slug' => $album->slug, 'created_at' => $album->created_at, 'published_at' => $album->published_at, 'description' => $album->description, 'cover_url' => $album->hasCover() ? $album->getCoverUrl(Image::NORMAL) : null, 'real_cover_url' => $album->getCoverUrl(Image::NORMAL), 'tracks' => $tracks], 200);
 }