'array', 'data' => 'array', 'trial_ends_at' => 'datetime', 'active_until' => 'datetime', ]; /** Stancl expects this to know what columns are NOT in the JSON `data` blob. */ public static function getCustomColumns(): array { return [ 'id', 'slug', 'name', 'display_name', 'city', 'phone', 'email', 'contact_name', 'status', 'plan_id', 'trial_ends_at', 'active_until', 'settings', 'created_at', 'updated_at', 'deleted_at', ]; } public function plan() { return $this->belongsTo(Plan::class); } public function users() { return $this->hasMany(User::class); } public function isActive(): bool { return in_array($this->status, ['active', 'trial'], true); } public function isAccessible(): bool { if ($this->status === 'archived' || $this->status === 'suspended') { return false; } if ($this->status === 'expired') { return false; } return true; } /** Get the URL for this tenant. */ public function url(?string $path = '/'): string { $central = config('app.central_domain') ?: 'service.mir.md'; return "https://{$this->slug}.{$central}{$path}"; } public function registerMediaCollections(): void { $this->addMediaCollection('logo')->singleFile(); $this->addMediaCollection('favicon')->singleFile(); } public function getLogoUrl(): ?string { $m = $this->getFirstMedia('logo'); return $m ? $m->getUrl() : null; } public function getFaviconUrl(): ?string { $m = $this->getFirstMedia('favicon'); return $m ? $m->getUrl() : null; } }