-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
107 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/Http/Controllers/API/Interaction/BatchLikeController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\API\Interaction; | ||
|
||
use App\Http\Requests\API\BatchInteractionRequest; | ||
use App\Models\Interaction; | ||
use Illuminate\Http\JsonResponse; | ||
|
||
class BatchLikeController extends Controller | ||
{ | ||
/** | ||
* Like several songs at once as the currently authenticated user. | ||
* | ||
* @param BatchInteractionRequest $request | ||
* | ||
* @return JsonResponse | ||
*/ | ||
function store(BatchInteractionRequest $request) | ||
{ | ||
return response()->json(Interaction::batchLike((array) $request->songs, $request->user())); | ||
} | ||
|
||
/** | ||
* Unlike several songs at once as the currently authenticated user. | ||
* | ||
* @param BatchInteractionRequest $request | ||
* | ||
* @return JsonResponse | ||
*/ | ||
public function destroy(BatchInteractionRequest $request) | ||
{ | ||
return response()->json(Interaction::batchUnlike((array) $request->songs, $request->user())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\API\Interaction; | ||
|
||
use App\Http\Controllers\Controller as BaseController; | ||
|
||
class Controller extends BaseController | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\API\Interaction; | ||
|
||
use App\Models\Interaction; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Http\Request; | ||
|
||
class LikeController extends Controller | ||
{ | ||
/** | ||
* Like or unlike a song as the currently authenticated user. | ||
* | ||
* @param Request $request | ||
* | ||
* @return JsonResponse | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
return response()->json(Interaction::toggleLike($request->song, $request->user())); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
app/Http/Controllers/API/Interaction/PlayCountController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?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); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters