mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 07:54:03 +00:00
Allow cloning specific routes by name
This commit is contained in:
parent
3b90c91763
commit
645232e53c
2 changed files with 14 additions and 5 deletions
|
|
@ -32,7 +32,7 @@ use Stancl\Tenancy\Resolvers\PathTenantResolver;
|
|||
class CloneRoutesAsTenant
|
||||
{
|
||||
protected array $routesToClone = [];
|
||||
protected Closure|null $cloneUsing = null;
|
||||
protected Closure|null $cloneUsing = null; // The callback should accept Route instance or the route name (string)
|
||||
protected Closure|null $shouldBeCloned = null;
|
||||
protected array $cloneRoutesWithMiddleware = ['clone'];
|
||||
|
||||
|
|
@ -59,6 +59,11 @@ class CloneRoutesAsTenant
|
|||
continue;
|
||||
}
|
||||
|
||||
if (is_string($route)) {
|
||||
$this->router->getRoutes()->refreshNameLookups();
|
||||
$route = $this->router->getRoutes()->getByName($route);
|
||||
}
|
||||
|
||||
$this->copyMiscRouteProperties($route, $this->createNewRoute($route));
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +91,7 @@ class CloneRoutesAsTenant
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function cloneRoute(Route $route): static
|
||||
public function cloneRoute(Route|string $route): static
|
||||
{
|
||||
$this->routesToClone[] = $route;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue