<?php

namespace App\Classes\Modules\Schedules\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
use App\Models\Schedule;
use App\Models\Transport;

class CreatesSchedule extends AbstractUpdateRelationshipRecord
{

    /**
     * @param Transport $transport
     * @param ScheduleObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(Transport $transport, ScheduleObject $object) {
        $model = new Schedule();

        $model->etd = $object->getETD();
        $model->eta = $object->getETA();
        $model->status = $object->getStatus();

        return $this->handler($transport->schedules(), $model);

    }
}
