<?php

namespace App\Models;

use App\Traits\BelongsToOrganization;
use App\Traits\BelongsToBranch;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class InventoryAdjustment extends Model
{
    use HasFactory, BelongsToOrganization, BelongsToBranch;

    protected $fillable = [
        'product_id',
        'user_id',
        'branch_id',
        'type',
        'quantity_before',
        'quantity_adjusted',
        'quantity_after',
        'reason',
        'organization_id',
    ];

    protected function casts(): array
    {
        return [
            'quantity_before' => 'integer',
            'quantity_adjusted' => 'integer',
            'quantity_after' => 'integer',
        ];
    }

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

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}
