2024-01-02 12:07:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
|
|
|
use App\Events\LibraryChanged;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Requests\API\UploadArtistImageRequest;
|
|
|
|
use App\Models\Artist;
|
|
|
|
use App\Services\MediaMetadataService;
|
|
|
|
|
|
|
|
class UploadArtistImageController extends Controller
|
|
|
|
{
|
|
|
|
public function __invoke(
|
|
|
|
UploadArtistImageRequest $request,
|
|
|
|
Artist $artist,
|
|
|
|
MediaMetadataService $mediaMetadataService
|
|
|
|
) {
|
2024-01-27 11:24:34 +00:00
|
|
|
$this->authorize('update', $artist);
|
|
|
|
|
2024-01-02 12:07:37 +00:00
|
|
|
$mediaMetadataService->writeArtistImage(
|
|
|
|
$artist,
|
|
|
|
$request->getFileContentAsBinaryString(),
|
|
|
|
$request->getFileExtension()
|
|
|
|
);
|
|
|
|
|
|
|
|
event(new LibraryChanged());
|
|
|
|
|
2024-01-27 11:24:34 +00:00
|
|
|
return response()->json(['image_url' => $artist->image]);
|
2024-01-02 12:07:37 +00:00
|
|
|
}
|
|
|
|
}
|