1 | <?php |
||
2 | |||
3 | namespace App\Http\Controllers\API\Interaction; |
||
4 | |||
5 | use App\Events\SongStartedPlaying; |
||
6 | use App\Http\Requests\API\Interaction\StorePlayCountRequest; |
||
7 | use Illuminate\Http\JsonResponse; |
||
8 | |||
9 | /** |
||
10 | * @group 3. Song interactions |
||
11 | */ |
||
12 | class PlayCountController extends Controller |
||
13 | { |
||
14 | /** |
||
15 | * Increase play count. |
||
16 | * |
||
17 | * Increase a song's play count as the currently authenticated user. |
||
18 | * This request should be made whenever a song is played. |
||
19 | * An "interaction" record including the song and current user's data will be returned. |
||
20 | * |
||
21 | * @bodyParam song string required The ID of the song. Example: 0146d01afb742b01f28ab8b556f9a75d |
||
22 | * |
||
23 | * @responseFile responses/interaction.json |
||
24 | * |
||
25 | * @return JsonResponse |
||
26 | */ |
||
27 | 1 | public function store(StorePlayCountRequest $request) |
|
28 | { |
||
29 | 1 | $interaction = $this->interactionService->increasePlayCount($request->song, $request->user()); |
|
30 | |||
31 | 1 | if ($interaction) { |
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
32 | 1 | event(new SongStartedPlaying($interaction->song, $interaction->user)); |
|
33 | } |
||
34 | |||
35 | 1 | return response()->json($interaction); |
|
36 | } |
||
37 | } |
||
38 |