<?php

namespace App\Models;

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

class CattleLocationMovement extends Model
{
    public const REASON_MANUAL_PASTURE = 'manual_pasture';

    public const REASON_FATTENING_ENTRY = 'fattening_entry';

    public const REASON_FATTENING_EXIT = 'fattening_exit';

    public const REASON_DEACTIVATION = 'deactivation';

    public const REASON_CALVING = 'calving';

    public const TYPE_PASTURE = 'pasture';

    public const TYPE_FATTENING = 'fattening';

    public const TYPE_UNASSIGNED = 'unassigned';

    protected $fillable = [
        'cattle_id',
        'reason',
        'from_type',
        'from_label',
        'to_type',
        'to_label',
        'fattening_lot_id',
        'moved_at',
        'notes',
        'user_id',
    ];

    protected $casts = [
        'moved_at' => 'date',
    ];

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

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

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