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

31 lines
785 B
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers\API;
use App\Events\LibraryChanged;
2022-07-29 06:47:10 +00:00
use App\Http\Controllers\Controller;
use App\Http\Requests\API\ArtistImageUpdateRequest;
use App\Models\Artist;
use App\Services\MediaMetadataService;
use Illuminate\Http\JsonResponse;
class ArtistImageController extends Controller
{
2022-07-29 06:47:10 +00:00
public function __construct(private MediaMetadataService $mediaMetadataService)
{
}
public function update(ArtistImageUpdateRequest $request, Artist $artist)
{
$this->mediaMetadataService->writeArtistImage(
$artist,
$request->getFileContentAsBinaryString(),
$request->getFileExtension()
);
event(new LibraryChanged());
return new JsonResponse(['imageUrl' => $artist->image]);
}
}