getAttribute($this->getTenantKeyName()); } /** Get the current tenant. */ public static function current(): static|null { return tenant(); } /** * Get the current tenant or throw an exception if tenancy is not initialized. * * @throws TenancyNotInitializedException */ public static function currentOrFail(): static { return static::current() ?? throw new TenancyNotInitializedException; } public function newCollection(array $models = []): TenantCollection { return new TenantCollection($models); } protected $dispatchesEvents = [ 'saving' => Events\SavingTenant::class, 'saved' => Events\TenantSaved::class, 'creating' => Events\CreatingTenant::class, 'created' => Events\TenantCreated::class, 'updating' => Events\UpdatingTenant::class, 'updated' => Events\TenantUpdated::class, 'deleting' => Events\DeletingTenant::class, 'deleted' => Events\TenantDeleted::class, ]; }