<?php

namespace App\Models;

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

class WarehouseOut extends Model
{
    protected $table = 'warehouse_out';

    protected $fillable = [
        'tanggal',
        'item_id',
        'qty',
        'note',
        'created_by',
    ];

    protected $casts = [
        'tanggal' => 'datetime',
        'qty' => 'decimal:2',
    ];

    public function item(): BelongsTo
    {
        return $this->belongsTo(WarehouseItem::class, 'item_id');
    }

    public function creator(): BelongsTo
    {
        return $this->belongsTo(User::class, 'created_by');
    }
}
