123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace App\Models;
- use App\Models\Scopes\TenantEnvScope;
- use Encore\Admin\Traits\DefaultDatetimeFormat;
- use Illuminate\Database\Eloquent\Relations\HasMany;
- use Stancl\Tenancy\Database\Concerns\HasDatabase;
- use Stancl\Tenancy\Database\Concerns\HasDomains;
- use Stancl\Tenancy\Database\Models\Tenant as BaseTenant;
- use Stancl\Tenancy\Contracts\TenantWithDatabase;
- /**
- * @method __call(string $method, array $parameters)
- * @method __callStatic(string $method, array $parameters)
- */
- class Tenant extends BaseTenant implements TenantWithDatabase
- {
- use HasDatabase, HasDomains;
- use DefaultDatetimeFormat;
- public function users(): HasMany
- {
- return $this->hasMany(GlobalUser::class, 'tenant_id');
- }
- protected static function booted(): void
- {
- if (php_sapi_name() === 'cli') {
- static::addGlobalScope(new TenantEnvScope());
- }
- }
- protected $casts = [
- ];
- public static function getCustomColumns(): array
- {
- return [
- 'id',
- 'name',
- 'email',
- 'company_name',
- 'expired_at',
- 'env'
- ];
- }
- }
|