koel/app/Http/Controllers/API/Podcast/UnsubscribeFromPodcastController.php

24 lines
645 B
PHP
Raw Normal View History

2024-05-19 05:49:42 +00:00
<?php
namespace App\Http\Controllers\API\Podcast;
use App\Http\Controllers\Controller;
use App\Models\Podcast;
2024-05-19 05:49:42 +00:00
use App\Models\User;
use App\Services\PodcastService;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Response;
class UnsubscribeFromPodcastController extends Controller
{
/** @param User $user */
public function __invoke(Podcast $podcast, PodcastService $podcastService, Authenticatable $user)
{
abort_unless($user->subscribedToPodcast($podcast), Response::HTTP_BAD_REQUEST);
$podcastService->unsubscribeUserFromPodcast($user, $podcast);
return response()->json();
}
}