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

29 lines
768 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 App\Models\Interaction;
use Illuminate\Http\JsonResponse;
class PlayCountController extends Controller
{
/**
* Increase a song's play count as the currently authenticated user.
*
* @param StorePlayCountRequest $request
2017-08-06 09:43:59 +00:00
*
* @return JsonResponse
*/
public function store(StorePlayCountRequest $request)
2017-08-06 09:43:59 +00:00
{
$interaction = Interaction::increasePlayCount($request->song, $request->user());
if ($interaction) {
event(new SongStartedPlaying($interaction->song, $interaction->user));
}
return response()->json($interaction);
}
}