<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Attributes\Guarded;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

#[Guarded(['id'])]
class CuttingMaterial extends Model
{
    use HasFactory, SoftDeletes;

    protected function casts(): array
    {
        return [
            'material_usage' => 'integer',
            'material_result' => 'integer',
        ];
    }

    public function combination(): BelongsTo
    {
        return $this->belongsTo(CuttingMaterialCombination::class, 'combination_id');
    }

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

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

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