<?php

namespace App\Libraries\DeleteData\SoftwareSettings;

use App\Libraries\DeleteData\DeleteData;
use App\Libraries\PublicImageStorage;
use Modules\Fleet\Models\Fleetimage as FleetimageModel;

class FleetImage extends DeleteData
{
    public function __construct()
    {
        $this->title = 'fleet images';
        $this->model = new FleetimageModel;
        $this->model->select('fleetimages.id, fleetimages.img_path AS name');
    }

    public function deleteCallback(string $table, array $deleteData = [])
    {
        if ($table === 'fleetimages') {
            foreach ($deleteData as $single) {
                PublicImageStorage::delete($single->name ?? '');
            }
        }
    }
}
