2024-01-02 12:07:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Requests\API\UploadAlbumCoverRequest;
|
|
|
|
use App\Models\Album;
|
|
|
|
use App\Services\MediaMetadataService;
|
|
|
|
|
|
|
|
class UploadAlbumCoverController extends Controller
|
|
|
|
{
|
|
|
|
public function __invoke(UploadAlbumCoverRequest $request, Album $album, MediaMetadataService $mediaMetadataService)
|
|
|
|
{
|
2024-01-27 11:24:34 +00:00
|
|
|
$this->authorize('update', $album);
|
|
|
|
|
2024-01-02 12:07:37 +00:00
|
|
|
$mediaMetadataService->writeAlbumCover(
|
|
|
|
$album,
|
|
|
|
$request->getFileContentAsBinaryString(),
|
|
|
|
$request->getFileExtension()
|
|
|
|
);
|
|
|
|
|
2024-01-27 11:24:34 +00:00
|
|
|
return response()->json(['cover_url' => $album->cover]);
|
2024-01-02 12:07:37 +00:00
|
|
|
}
|
|
|
|
}
|