<?php

namespace App\Models;

use App\Models\Concerns\BelongsToBranch;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;

#[Fillable(['branch_id', 'product_id', 'user_id', 'source_type', 'source_id', 'quantity_change', 'quantity_after', 'note'])]
class StockMutation extends Model
{
    use BelongsToBranch;

    protected function casts(): array
    {
        return [
            'quantity_change' => 'decimal:3',
            'quantity_after' => 'decimal:3',
        ];
    }

    public function product()
    {
        return $this->belongsTo(Product::class);
    }
}
