mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 10:14:03 +00:00
Merge 4054f55415 into a675535e98
This commit is contained in:
commit
85772e864e
1 changed files with 11 additions and 2 deletions
|
|
@ -11,6 +11,8 @@ Even though [`tenants:run`]({{ $page->link('console-commands#run') }}) lets you
|
||||||
|
|
||||||
To make a command tenant-aware, utilize the `TenantAwareCommand` trait:
|
To make a command tenant-aware, utilize the `TenantAwareCommand` trait:
|
||||||
```php
|
```php
|
||||||
|
use Stancl\Tenancy\Concerns\TenantAwareCommand;
|
||||||
|
|
||||||
class MyCommand extends Command
|
class MyCommand extends Command
|
||||||
{
|
{
|
||||||
use TenantAwareCommand;
|
use TenantAwareCommand;
|
||||||
|
|
@ -20,8 +22,8 @@ class MyCommand extends Command
|
||||||
However, this trait requires you to implement a `getTenants()` method that returns an array of `Tenant` instances.
|
However, this trait requires you to implement a `getTenants()` method that returns an array of `Tenant` instances.
|
||||||
|
|
||||||
If you don't want to implement the options/arguments yourself, you may use one of these two traits:
|
If you don't want to implement the options/arguments yourself, you may use one of these two traits:
|
||||||
- `HasATenantsOption` - accepts multiple tenant IDs, optional -- by default the command is executed for all tenants
|
- `Stancl\Tenancy\Concerns\HasATenantsOption` - accepts multiple tenant IDs, optional -- by default the command is executed for all tenants
|
||||||
- `HasATenantArgument` - accepts a single tenant ID, required argument
|
- `Stancl\Tenancy\Concerns\HasATenantArgument` - accepts a single tenant ID, required argument
|
||||||
|
|
||||||
These traits implement the `getTenants()` method needed by `TenantAwareCommand`.
|
These traits implement the `getTenants()` method needed by `TenantAwareCommand`.
|
||||||
|
|
||||||
|
|
@ -30,6 +32,10 @@ These traits implement the `getTenants()` method needed by `TenantAwareCommand`.
|
||||||
So if you use these traits in combination with `TenantAwareCommand`, you won't have to change a thing in your command:
|
So if you use these traits in combination with `TenantAwareCommand`, you won't have to change a thing in your command:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
|
||||||
|
use Stancl\Tenancy\Concerns\TenantAwareCommand;
|
||||||
|
use Stancl\Tenancy\Concerns\HasATenantsOption;
|
||||||
|
|
||||||
class FooCommand extends Command
|
class FooCommand extends Command
|
||||||
{
|
{
|
||||||
use TenantAwareCommand, HasATenantsOption;
|
use TenantAwareCommand, HasATenantsOption;
|
||||||
|
|
@ -40,6 +46,9 @@ class FooCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use Stancl\Tenancy\Concerns\TenantAwareCommand;
|
||||||
|
use Stancl\Tenancy\Concerns\HasATenantArgument;
|
||||||
|
|
||||||
class BarCommand extends Command
|
class BarCommand extends Command
|
||||||
{
|
{
|
||||||
use TenantAwareCommand, HasATenantArgument;
|
use TenantAwareCommand, HasATenantArgument;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue