mirror of
https://github.com/koel/koel
synced 2024-12-11 05:02:27 +00:00
28 lines
755 B
PHP
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);
|
|
}
|
|
}
|