koel/app/Http/Controllers/API/Interaction/PlayCountController.php
2018-08-18 14:27:44 +02:00

28 lines
755 B
PHP

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