33 lines
565 B
PHP
33 lines
565 B
PHP
<?php
|
|
|
|
namespace App\Services\Tenant;
|
|
|
|
use App\Models\Business;
|
|
|
|
final class TenantContext
|
|
{
|
|
private ?Business $business = null;
|
|
|
|
public function set(Business $business): void
|
|
{
|
|
$this->business = $business;
|
|
}
|
|
|
|
public function business(): ?Business
|
|
{
|
|
return $this->business;
|
|
}
|
|
|
|
public function id(): ?string
|
|
{
|
|
return $this->business?->getKey();
|
|
}
|
|
|
|
public function require(): Business
|
|
{
|
|
abort_unless($this->business, 404, 'Business not found.');
|
|
|
|
return $this->business;
|
|
}
|
|
}
|