<?php

namespace App\Classes\Modules\Documents\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Models\Document;
use Carbon\Carbon;

class ApprovesDocument extends AbstractUpdateRecord
{

    /**
     * @param Document $model
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(Document $model)
    {
        $model->status = ApprovalStatus::APPROVED;
        $model->approver = Auth()->user()->id;
        $model->approval_date = Carbon::now();

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