koel/app/Http/Controllers/API/PublicizeSongsController.php

25 lines
687 B
PHP
Raw Normal View History

<?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;
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
{
/** @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);
$songs->each(fn ($song) => $this->authorize('own', $song));
$songService->markSongsAsPublic($songs);
return response()->noContent();
}
}