<?php

namespace App\Http\Controllers\Backend;

use App\Http\Controllers\Controller;
use App\Models\Polymorphs\Media;
use App\Services\CartTempDeletion;
use Illuminate\Http\JsonResponse;

class MediaController extends Controller{

    public function __construct(){


      //  $this->middleware('permission:media-delete')->only(["delete"]);

    }


    /**
     * @param Media $media
     * @param CartTempDeletion $cartTempDeletion
     * @return JsonResponse
     */
    public function addToDeletion(Media $media, CartTempDeletion $cartTempDeletion): JsonResponse
    {

        $cartTempDeletion->addMediaToDelete($media);
       // write_log("media",$cartTempDeletion->getContent());
        clear_cache();

        return response()->json([
            'success' => true,
            'message' => 'Image supprimée.',
            'medias-deletion' => $cartTempDeletion->getContent()
        ]);

    }
}
