<?php

namespace App\Classes\Modules\Addresses\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
use App\Models\Address;

class UpdatesAddress extends AbstractUpdateRecord
{

    /**
     * @param Address $model
     * @param AddressObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(Address $model, AddressObject $object) {

        $model->reference = $object->getReference();
        $model->street_one = $object->getStreetOne();
        $model->street_two = $object->getStreetTwo();
        $model->district_id = $object->getDistrictId();
        $model->state_id = $object->getStateId();
        $model->postcode = $object->getPostCode();
        $model->country_id = $object->getCountryId();

        return $this->handler($model);

    }
}