app\models\Album::getInfo PHP Method

getInfo() public method

Get extra information about the album from Last.fm.
public getInfo ( ) : array | false
return array | false
    public function getInfo()
    {
        if ($this->isUnknown()) {
            return false;
        }
        $info = Lastfm::getAlbumInfo($this->name, $this->artist->name);
        // If our current album has no cover, and Last.fm has one, why don't we steal it?
        // Great artists steal for their great albums!
        if (!$this->has_cover && is_string($image = array_get($info, 'image')) && ini_get('allow_url_fopen')) {
            $extension = explode('.', $image);
            $this->writeCoverFile(file_get_contents($image), last($extension));
            $info['cover'] = $this->cover;
        }
        return $info;
    }

Usage Example

Example #1
0
 /**
  * Get extra information about an album via Last.fm.
  *
  * @param Album $album
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getInfo(Album $album)
 {
     return response()->json($album->getInfo());
 }