<?php

namespace App\Models;

use App\Observers\EggCollectionItemObserver;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

#[ObservedBy(EggCollectionItemObserver::class)]
class EggCollectionItem extends Model
{
    use HasFactory;

    protected $guarded = ['id'];

    protected $casts = [
        'is_broken' => 'boolean',
        'quantity' => 'decimal:2',
    ];

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

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