<?php

declare(strict_types=1);

namespace App\Models;

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

class DberpStocktakeSerialNumberDifference extends Model
{
    protected $table = 'dberp_stocktake_serial_number_differences';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'stocktake_order_id',
        'stocktake_order_item_id',
        'product_id',
        'product_sku_id',
        'warehouse_id',
        'serial_no',
        'difference_type',
        'system_status',
        'system_warehouse_id',
        'system_is_enabled',
        'counted_in_actual',
        'status',
        'sort_order',
    ];

    protected function casts(): array
    {
        return [
            'stocktake_order_id' => 'integer',
            'stocktake_order_item_id' => 'integer',
            'product_id' => 'integer',
            'product_sku_id' => 'integer',
            'warehouse_id' => 'integer',
            'system_warehouse_id' => 'integer',
            'system_is_enabled' => 'boolean',
            'counted_in_actual' => 'boolean',
            'sort_order' => 'integer',
        ];
    }

    public function stocktakeOrder(): BelongsTo
    {
        return $this->belongsTo(DberpStocktakeOrder::class, 'stocktake_order_id');
    }

    public function stocktakeOrderItem(): BelongsTo
    {
        return $this->belongsTo(DberpStocktakeOrderItem::class, 'stocktake_order_item_id');
    }

    public function product(): BelongsTo
    {
        return $this->belongsTo(DberpProduct::class, 'product_id');
    }

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

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