<?php
 namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; class DomainCost extends Model { use HasFactory, SoftDeletes; protected $fillable = [ 'tld_id', 'registrar', 'is_active', 'metadata', ]; protected $casts = [ 'is_active' => 'boolean', 'metadata' => 'array', ]; public function tld() { return $this->belongsTo(Tld::class, 'tld_id'); } public function registrar() { return $this->belongsTo(Registrar::class, 'registrar', 'name'); } public function pricings() { return $this->hasMany(Pricing::class, 'relation_id') ->where('type', 'domain_cost') ->orderBy('period', 'asc'); } public function isCurrentlyActive(): bool { return (bool) $this->is_active; } public function scopeActive($query) { return $query->where('is_active', true); } public function scopeByTld($query, $tldId) { return $query->where('tld_id', $tldId); } public function scopeByRegistrar($query, $registrar) { return $query->where('registrar', $registrar); } } 