2024-01-02 12:07:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Requests\API\UploadArtistImageRequest;
|
|
|
|
use App\Models\Artist;
|
|
|
|
use App\Services\MediaMetadataService;
|
2024-07-11 15:09:08 +00:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2024-01-02 12:07:37 +00:00
|
|
|
|
|
|
|
class UploadArtistImageController extends Controller
|
|
|
|
{
|
2024-03-19 22:48:12 +00:00
|
|
|
public function __invoke(UploadArtistImageRequest $request, Artist $artist, MediaMetadataService $metadataService)
|
|
|
|
{
|
2024-01-27 11:24:34 +00:00
|
|
|
$this->authorize('update', $artist);
|
2024-03-19 22:48:12 +00:00
|
|
|
$metadataService->writeArtistImage($artist, $request->getFileContent());
|
2024-01-02 12:07:37 +00:00
|
|
|
|
2024-07-11 15:09:08 +00:00
|
|
|
Cache::delete("artist.info.$artist->id");
|
|
|
|
|
2024-01-27 11:24:34 +00:00
|
|
|
return response()->json(['image_url' => $artist->image]);
|
2024-01-02 12:07:37 +00:00
|
|
|
}
|
|
|
|
}
|