cyberfly
9/26/2018 - 9:10 AM

Spatie Media Library delete by media id

    public function destroy(Request $request, $attachment_id)
    {
        $media = $this->media->find($attachment_id);

        $model_id = $media->model_id;
        $model_type = $media->model_type;

        $associated_model = $model_type::where('id', $model_id)->first();

        $associated_model->deleteMedia($attachment_id);

        return $this->response->noContent();
    }