<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class DberpDocumentQuery extends Model
{
    public $timestamps = false;

    protected $table = 'dberp_document_queries';

    protected $primaryKey = 'row_id';

    public $incrementing = false;

    protected $keyType = 'int';

    protected function casts(): array
    {
        return [
            'row_id' => 'integer',
            'business_time' => 'datetime',
            'total_quantity' => 'decimal:4',
            'total_amount' => 'decimal:4',
            'customer_id' => 'integer',
            'supplier_id' => 'integer',
            'warehouse_id' => 'integer',
            'to_warehouse_id' => 'integer',
            'handler_employee_id' => 'integer',
        ];
    }

    public function customer(): BelongsTo
    {
        return $this->belongsTo(DberpCustomer::class, 'customer_id');
    }

    public function supplier(): BelongsTo
    {
        return $this->belongsTo(DberpSupplier::class, 'supplier_id');
    }

    public function warehouse(): BelongsTo
    {
        return $this->belongsTo(DberpWarehouse::class, 'warehouse_id');
    }

    public function handlerEmployee(): BelongsTo
    {
        return $this->belongsTo(DberpEmployee::class, 'handler_employee_id');
    }
}
