-
app/Tiles/TeamMember/Commands/FetchCurrentTracksCommand.php
Open in GitHubuse 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!'); } }