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

35 lines
1 KiB
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;
/**
* @group 3. Song interactions
*/
2017-08-06 09:43:59 +00:00
class PlayCountController extends Controller
{
/**
2020-04-12 08:08:37 +00:00
* Increase play count.
*
2017-08-06 09:43:59 +00:00
* Increase a song's play count as the currently authenticated user.
* This request should be made whenever a song is played.
* An "interaction" record including the song and current user's data will be returned.
*
* @bodyParam song string required The ID of the song. Example: 0146d01afb742b01f28ab8b556f9a75d
*
* @responseFile responses/interaction.json
2017-08-06 09:43:59 +00:00
*
* @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());
event(new SongStartedPlaying($interaction->song, $interaction->user));
2017-08-06 09:43:59 +00:00
return response()->json($interaction);
}
}