<?php

namespace App\Classes\Modules\Orders\Services\Attachments;


use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
use App\Classes\Modules\Orders\DataTransferObjects\ShippingArrangementObject;
use App\Models\ShippingArrangement;

class UpdatesShippingArrangement
{

    /** @var ShippingArrangement */
    private $repository;

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

    public function execute(int $orderId, ShippingArrangementObject $arrangement){
        $arrangement = $this->repository->updateOrCreate(['order_id' => $orderId],
            ['container_no' => $arrangement->getContainerNumber(), 'seal_no' => $arrangement->getSealNumber()]);

        return $arrangement->id;
    }


}