1
0
Fork 0
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:
Samuel Štancl 2020-05-10 20:16:08 +02:00
parent cb2bd018aa
commit 494d274798
4 changed files with 83 additions and 5 deletions

View file

@ -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;