2024-01-08 22:21:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Requests\API\ChangeSongsVisibilityRequest;
|
2024-01-09 18:34:40 +00:00
|
|
|
use App\Models\Song;
|
2024-01-08 22:21:21 +00:00
|
|
|
use App\Models\User;
|
|
|
|
use App\Services\SongService;
|
|
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
|
|
|
|
2024-01-16 21:14:14 +00:00
|
|
|
class PublicizeSongsController extends Controller
|
2024-01-08 22:21:21 +00:00
|
|
|
{
|
|
|
|
/** @param User $user */
|
2024-01-16 21:14:14 +00:00
|
|
|
public function __invoke(ChangeSongsVisibilityRequest $request, SongService $songService, Authenticatable $user)
|
|
|
|
{
|
2024-01-10 23:11:45 +00:00
|
|
|
$songs = Song::query()->findMany($request->songs);
|
2024-01-08 22:21:21 +00:00
|
|
|
$songs->each(fn ($song) => $this->authorize('own', $song));
|
|
|
|
|
2024-01-16 21:14:14 +00:00
|
|
|
$songService->publicizeSongs($songs);
|
2024-01-08 22:21:21 +00:00
|
|
|
|
|
|
|
return response()->noContent();
|
|
|
|
}
|
|
|
|
}
|