mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 16:34:04 +00:00
Add a hook that should run before trying to fetch tenants
Signed-off-by: michael lundbøl <michael.lundboel@gmail.com>
This commit is contained in:
parent
726a0462eb
commit
39c1e65172
4 changed files with 103 additions and 0 deletions
47
tests/Etc/AddUserConditionally.php
Normal file
47
tests/Etc/AddUserConditionally.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy\Tests\Etc;
|
||||
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
use Stancl\Tenancy\Traits\HasATenantsOption;
|
||||
use Stancl\Tenancy\Traits\TenantAwareCommand;
|
||||
|
||||
class AddUserConditionally extends Command
|
||||
{
|
||||
use TenantAwareCommand, HasATenantsOption;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'user:add_conditionally {--stop}';
|
||||
|
||||
public function beforeRunningTenants()
|
||||
{
|
||||
if ($this->option('stop')) {
|
||||
$this->error('You stopped the command conditionally');
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
User::create([
|
||||
'name' => Str::random(10),
|
||||
'email' => Str::random(10) . '@gmail.com',
|
||||
'email_verified_at' => now(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
'remember_token' => Str::random(10),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,5 +16,6 @@ class ConsoleKernel extends Kernel
|
|||
protected $commands = [
|
||||
ExampleCommand::class,
|
||||
AddUserCommand::class,
|
||||
AddUserConditionally::class
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue