koel/app/Http/Controllers/API/Interaction/PlayCountController.php

27 lines
703 B
PHP
Raw Normal View History

2017-08-06 09:43:59 +00:00
<?php
namespace App\Http\Controllers\API\Interaction;
use App\Events\SongStartedPlaying;
use App\Http\Requests\API\Interaction\StorePlayCountRequest;
2017-08-06 09:43:59 +00:00
use Illuminate\Http\JsonResponse;
class PlayCountController extends Controller
{
/**
* Increase a song's play count as the currently authenticated user.
*
* @return JsonResponse
*/
public function store(StorePlayCountRequest $request)
2017-08-06 09:43:59 +00:00
{
2018-08-18 12:27:26 +00:00
$interaction = $this->interactionService->increasePlayCount($request->song, $request->user());
2017-08-06 09:43:59 +00:00
if ($interaction) {
event(new SongStartedPlaying($interaction->song, $interaction->user));
}
return response()->json($interaction);
}
}