mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:44:04 +00:00
Finish path identification - configurability & exception handling
This commit is contained in:
parent
cb2bd018aa
commit
494d274798
4 changed files with 83 additions and 5 deletions
|
|
@ -9,13 +9,15 @@ use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedByPathException;
|
|||
|
||||
class PathTenantResolver implements TenantResolver
|
||||
{
|
||||
public static $tenantParameterName = 'tenant';
|
||||
|
||||
public function resolve(...$args): Tenant
|
||||
{
|
||||
/** @var Route $route */
|
||||
$route = $args[0];
|
||||
|
||||
if ($id = $route->parameter('tenant')) {
|
||||
$route->forgetParameter('tenant');
|
||||
if ($id = $route->parameter(static::$tenantParameterName)) {
|
||||
$route->forgetParameter(static::$tenantParameterName);
|
||||
|
||||
if ($tenant = config('tenancy.tenant_model')::find($id)) {
|
||||
return $tenant;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue