mirror of
https://github.com/koel/koel
synced 2024-12-22 10:33:16 +00:00
28 lines
708 B
PHP
28 lines
708 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API\Interaction;
|
|
|
|
use App\Events\SongStartedPlaying;
|
|
use App\Models\Interaction;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class PlayCountController extends Controller
|
|
{
|
|
/**
|
|
* Increase a song's play count as the currently authenticated user.
|
|
*
|
|
* @param Request $request
|
|
*
|
|
* @return JsonResponse
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
$interaction = Interaction::increasePlayCount($request->song, $request->user());
|
|
if ($interaction) {
|
|
event(new SongStartedPlaying($interaction->song, $interaction->user));
|
|
}
|
|
|
|
return response()->json($interaction);
|
|
}
|
|
}
|