<?php

namespace App\Models;

use App\Models\Concerns\InteractsWithActivityLog;
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 CuttingResult extends Model
{
    // 1. Use Trait
    use HasFactory, InteractsWithActivityLog, SoftDeletes;

    // 2. Casting
    protected function casts(): array
    {
        return [
            'cutting_result' => 'integer',
            'original_outside_sample' => 'integer',
            'sample' => 'integer',
        ];
    }

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

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

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