<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class AgreementLog extends BaseModel
{
    use HasFactory;

    protected $table = 'agreement_log';

    public static function addAgreementLog($admin, $order_id, $agreement_id, $remark = null)
    {
        $data = [
            'user_id' => $admin->id,
            'user_name' => $admin->name ?? '',
            'user_mobile' => $admin->mobile ?? '',
            'order_id' => $order_id,
            'agreement_id' => $agreement_id,
            'remark' => $remark
        ];
        self::create($data);
    }

    public function agreement()
    {
        return $this->hasOne(Agreement::class, 'id', 'agreement_id');
    }
}
