2020-04-26 19:09:43 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
|
|
|
use App\Events\LibraryChanged;
|
|
|
|
use App\Http\Requests\API\ArtistImageUpdateRequest;
|
|
|
|
use App\Models\Artist;
|
|
|
|
use App\Services\MediaMetadataService;
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
|
|
|
|
class ArtistImageController extends Controller
|
|
|
|
{
|
2021-06-05 10:47:56 +00:00
|
|
|
private MediaMetadataService $mediaMetadataService;
|
2020-04-26 19:09:43 +00:00
|
|
|
|
|
|
|
public function __construct(MediaMetadataService $mediaMetadataService)
|
|
|
|
{
|
|
|
|
$this->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]);
|
|
|
|
}
|
|
|
|
}
|