<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Laravel\Sanctum\HasApiTokens;

class Website extends Model
{
    use HasApiTokens, HasFactory;

    protected $fillable = [
        'name',
        'domain',
        'tier_id',
        'cache_hit_rate_limit',
        'external_api_rate_limit',
        'is_active',
        'bypass_rate_limit',
    ];

    protected function casts(): array
    {
        return [
            'is_active' => 'boolean',
            'bypass_rate_limit' => 'boolean',
        ];
    }

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

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