<?php

namespace Kylin\Catering\Models;

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

/**
 * 库存变动日志
 */
class StockLog extends Model
{
    protected $table = 'catering_stock_logs';
    protected $fillable = [
        'stock_id',
        'type',
        'quantity',
        'before_stock',
        'after_stock',
        'remark',
    ];

    protected $casts = [
        'stock_id' => 'integer',
        'quantity' => 'decimal:2',
        'before_stock' => 'decimal:2',
        'after_stock' => 'decimal:2',
    ];

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