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

30 lines
772 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\Repositories\SongRepository;
use App\Services\SongService;
use Illuminate\Contracts\Auth\Authenticatable;
class MakeSongsPublicController extends Controller
{
/** @param User $user */
public function __invoke(
ChangeSongsVisibilityRequest $request,
SongRepository $repository,
SongService $songService,
Authenticatable $user
) {
2024-01-09 18:34:40 +00:00
$songs = Song::find($request->songs);
$songs->each(fn ($song) => $this->authorize('own', $song));
$songService->makeSongsPublic($songs);
return response()->noContent();
}
}