'boolean', 'is_featured' => 'boolean', 'sort_order' => 'integer', ]; } public function users(): HasMany { return $this->hasMany(User::class); } public function scopeActive(Builder $query): Builder { return $query->where('active', true); } public function scopeOrdered(Builder $query): Builder { return $query ->orderByDesc('is_featured') ->orderBy('sort_order') ->orderBy('name_common'); } public function getFlagCssClassAttribute(): ?string { $iso2 = strtoupper((string) $this->iso2); if (! preg_match('/^[A-Z]{2}$/', $iso2)) { return null; } return 'fi fi-'.strtolower($iso2); } public function getLocalFlagPathAttribute(): ?string { $iso2 = strtoupper((string) $this->iso2); if (! preg_match('/^[A-Z]{2}$/', $iso2)) { return null; } return '/gfx/flags/shiny/24/'.rawurlencode($iso2).'.png'; } }