<?php

namespace Kylin\Logistics\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Kylin\Logistics\Enums\CargoStatus;
use Kylin\Logistics\Enums\SignType;

/**
 * 签收记录模型
 *
 * 记录运单签收信息，包括签收人、签收照片、签收方式等。
 *
 * @property string $signer_name  签收人姓名
 * @property string $signer_phone 签收人电话
 * @property string $sign_type    签收方式
 */
class SignRecord extends Model
{
    public $timestamps = false;

    protected $table = 'kylin_log_sign_records';

    protected $fillable = [
        'waybill_id', 'signer_name', 'signer_phone',
        'sign_time', 'sign_type', 'sign_photo',
        'sign_signature', 'cargo_status', 'exception_remark',
        'sign_lng', 'sign_lat', 'created_at',
    ];

    protected $casts = [
        'sign_type' => SignType::class,
        'cargo_status' => CargoStatus::class,
        'sign_time' => 'datetime',
        'sign_lng' => 'decimal:12,8',
        'sign_lat' => 'decimal:12,8',
        'created_at' => 'datetime',
    ];

    public function waybill(): BelongsTo
    {
        return $this->belongsTo(Waybill::class);
    }
}
