1
0
Fork 0
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:
michael lundbøl 2020-05-06 21:59:16 +02:00
parent 726a0462eb
commit 39c1e65172
No known key found for this signature in database
GPG key ID: 213C976E2CFD1CAF
4 changed files with 103 additions and 0 deletions

View 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),
]);
}
}

View file

@ -16,5 +16,6 @@ class ConsoleKernel extends Kernel
protected $commands = [
ExampleCommand::class,
AddUserCommand::class,
AddUserConditionally::class
];
}