mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 19:14:04 +00:00
Rewrite old tests
This commit is contained in:
parent
64383b4c56
commit
89936187ce
71 changed files with 698 additions and 3203 deletions
|
|
@ -19,7 +19,7 @@ class PathTenantResolver implements TenantResolver
|
|||
if ($id = $route->parameter(static::$tenantParameterName)) {
|
||||
$route->forgetParameter(static::$tenantParameterName);
|
||||
|
||||
if ($tenant = config('tenancy.tenant_model')::find($id)) {
|
||||
if ($tenant = tenancy()->find($id)) {
|
||||
return $tenant;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
21
src/Resolvers/RequestDataTenantResolver.php
Normal file
21
src/Resolvers/RequestDataTenantResolver.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy\Resolvers;
|
||||
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\Contracts\TenantResolver;
|
||||
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedByRequestDataException;
|
||||
|
||||
class RequestDataTenantResolver implements TenantResolver
|
||||
{
|
||||
public function resolve(...$args): Tenant
|
||||
{
|
||||
$payload = $args[0];
|
||||
|
||||
if ($payload && $tenant = tenancy()->find($payload)) {
|
||||
return $tenant;
|
||||
}
|
||||
|
||||
throw new TenantCouldNotBeIdentifiedByRequestDataException($payload);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue