Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

spatie/dashboard.spatie.be

1947 stars
1 code files
View spatie/dashboard.spatie.be on GitHub

app/Tiles/TeamMember/Commands/FetchCurrentTracksCommand.php

Open in GitHub
use Illuminate\Console\Command;
 
class FetchCurrentTracksCommand extends Command
{
//
public function handle()
{
$this->info('Fetching current tracks');
 
$lastFm = new NowPlaying(config('services.last-fm.api_key'));
 
collect($this->lastFmUsers)
->each(function (string $teamMemberName, string $lastFmUserName) use ($lastFm) {
$teamMemberStore = TeamMemberStore::find($teamMemberName);
 
try {
$currentTrack = $lastFm->getTrackInfo($lastFmUserName);
 
$currentTrack
? $teamMemberStore->setNowPlaying($currentTrack)
: $teamMemberStore->setNothingPlaying();
} catch (Exception $exception) {
report($exception);
}
});
 
$this->info('All done!');
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.