I've written a package that allows you to connect with the last.fm API. With last.fm you can track which music you listen to. Through the API you can retrieve some cool statistics. Checkout https://github.com/barryvanveen/lastfm for the full readme and more examples.
// Install with Composer
composer require barryvanveen/lastfm
// Update config/app.php and register the LastfmServiceProvider
'providers' => [
...
Barryvanveen\Lastfm\LastfmServiceprovider::class,
];
// Publish the config file and configure your API key in /config/lastfm.php
php artisan vendor:publish --provider="Barryvanveen\Lastfm\LastfmServiceProvider"
/**
* Basic example:
* - use dependency injection to get the Lastfm class
* - retrieve a list of top albums that you listened to
* - assign the result to the view
*/
use Barryvanveen\Lastfm\Lastfm;
public function index(Lastfm $lastfm)
{
$albums = $lastfm->userTopAlbums('AnyUsername')->get();
return view('home', compact('albums'));
}
/**
* More advanced example:
* - use dependency injection to get the Lastfm class
* - retrieve a list of top artists
* limit to max 5 results
* only use statistics from the last week
* - assign the results to the view
*/
use Barryvanveen\Lastfm\Lastfm;
public function index(Lastfm $lastfm)
{
$artists = $lastfm->userTopArtists('AnyUsername')
->period(Barryvanveen\Lastfm\Constants::PERIOD_WEEK)
->limit(5)
->get();
return view('home', compact('artists'));
}