<?php

namespace App\Classes\Modules\PackingLists\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\General\Interfaces\Packable;
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
use App\Models\PackingList;

class CreatesNullOrderPackingList extends AbstractUpdateRecord
{
    /**
     * @param PackingListObject $object
     * @param Packable $packable
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(PackingListObject $object) {
        $model = new PackingList();

        $model->reference = $object->getReference();
        $model->claimant_id = $object->getClaimantId();
        $model->type = $object->getType();
        $model->status = $object->getStatus();
        $model->reference_contract = $object->getContractReference();
        $model->owner_type = 'App\Models\Order';
        $model->owner_id = 1;

        return $this->handler($model);
    }
}
