<?php

declare(strict_types=1);

namespace App\Models;

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

final class RssFeedSource extends Model
{
    protected $fillable = [
        'name',
        'url',
        'is_active',
        'sort_order',
        'last_synced_at',
        'last_error',
    ];

    protected function casts(): array
    {
        return [
            'is_active' => 'boolean',
            'sort_order' => 'integer',
            'last_synced_at' => 'datetime',
            'created_at' => 'datetime',
            'updated_at' => 'datetime',
        ];
    }

    /**
     * @return HasMany<RssFeedEntry, $this>
     */
    public function entries(): HasMany
    {
        return $this->hasMany(RssFeedEntry::class, 'rss_feed_source_id');
    }
}
