38 lines
711 B
PHP
38 lines
711 B
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
class BusinessContext
|
|
{
|
|
protected static ?int $businessId = null;
|
|
|
|
protected static ?int $userId = null;
|
|
|
|
public static function set(?int $businessId, ?int $userId = null): void
|
|
{
|
|
static::$businessId = $businessId;
|
|
static::$userId = $userId;
|
|
}
|
|
|
|
public static function clear(): void
|
|
{
|
|
static::$businessId = null;
|
|
static::$userId = null;
|
|
}
|
|
|
|
public static function id(): ?int
|
|
{
|
|
return static::$businessId;
|
|
}
|
|
|
|
public static function userId(): ?int
|
|
{
|
|
return static::$userId;
|
|
}
|
|
|
|
public static function isActive(): bool
|
|
{
|
|
return static::$businessId !== null;
|
|
}
|
|
}
|