<?php

namespace App\Models;

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

/**
 * @property int $id
 * @property int $product_id
 * @property int $tld_id
 * @property int $client_usage_limit
 * @property int $is_active
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 *
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ProductFreeDomainTld newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ProductFreeDomainTld newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ProductFreeDomainTld query()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ProductFreeDomainTld whereClientUsageLimit($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ProductFreeDomainTld whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ProductFreeDomainTld whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ProductFreeDomainTld whereIsActive($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ProductFreeDomainTld whereProductId($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ProductFreeDomainTld whereTldId($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ProductFreeDomainTld whereUpdatedAt($value)
 *
 * @property-read \App\Models\Product|null $product
 * @property-read \App\Models\Tld|null $tld
 *
 * @mixin \Eloquent
 */
class ProductFreeDomainTld extends Model
{
    use HasFactory;

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'product_id',
        'tld_id',
        'client_usage_limit',
        'is_active',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'client_usage_limit' => 'integer',
        'is_active' => 'boolean',
    ];

    /**
     * Get the product that owns the free domain TLD.
     */
    public function product(): BelongsTo
    {
        return $this->belongsTo(Product::class);
    }

    /**
     * Get the TLD that owns the free domain TLD.
     */
    public function tld(): BelongsTo
    {
        return $this->belongsTo(Tld::class);
    }
}
