<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class FeedSchedule extends Model
{
    use HasFactory, SoftDeletes;

    protected $guarded = ['id'];

    protected function casts(): array
    {
        return [
            'scheduled_at' => 'datetime:H:i',
        ];
    }

    public function feeds(): BelongsToMany
    {
        return $this->belongsToMany(Feed::class, 'feed_feed_schedule')
            ->using(FeedFeedSchedule::class)
            ->withPivot('quantity')
            ->withTimestamps();
    }

    public function feedFeedSchedules(): HasMany
    {
        return $this->hasMany(FeedFeedSchedule::class);
    }
}
