<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class CattleHealthEvent extends Model
{
    public const TYPE_VACCINATION = 'vaccination';

    public const TYPE_DEWORMING = 'deworming';

    public const TYPE_ILLNESS = 'illness';

    public const TYPE_TREATMENT = 'treatment';

    public const TYPE_CHECKUP = 'checkup';

    public const OUTCOME_RECOVERED = 'recovered';

    public const OUTCOME_ONGOING = 'ongoing';

    public const OUTCOME_FATAL = 'fatal';

    protected $fillable = [
        'cattle_id',
        'event_type',
        'event_date',
        'title',
        'product_name',
        'cost',
        'outcome',
        'notes',
        'material_type_id',
        'material_expense_id',
        'user_id',
    ];

    protected $casts = [
        'event_date' => 'date',
        'cost' => 'decimal:2',
    ];

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

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

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

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