1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 06:04:03 +00:00
tenancy/tests/Etc/AddUserConditionally.php
michael lundbøl 39c1e65172
Add a hook that should run before trying to fetch tenants
Signed-off-by: michael lundbøl <michael.lundboel@gmail.com>
2020-05-06 22:15:18 +02:00

47 lines
1.1 KiB
PHP

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