<?php

namespace App\Classes\Modules\Warehouses\Services;


use App\Models\Warehouse;
use App\Http\Resources\Warehouse as WarehouseResource;

class DeletesWarehouse
{
    /** @var  Warehouse */
    private $repository;

    /**
     * DeletesWarehouse constructor.
     * @param Warehouse $repository
     */
    public function __construct(Warehouse $repository)
    {
        $this->repository = $repository;
    }

    public function execute(string $id){

        $warehouse = $this->repository->findOrFail($id);

        if($warehouse->delete()){
            return new WarehouseResource($warehouse);
        }
    }

}