Symlinked core-api, php-commerce, php-tenant into app/Core/. All migrations ran (50 tables). Tenant feature seeder ran. Workspace 'Lethean CIC' created with admin user Charon and 'Lethean Registrar' namespace. SetupWorkspace artisan command for repeatable provisioning. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
74 lines
2.4 KiB
PHP
74 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Mod\Names\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* Create the initial Lethean CIC workspace and admin user.
|
|
*
|
|
* php artisan names:setup-workspace
|
|
*/
|
|
class SetupWorkspace extends Command
|
|
{
|
|
protected $signature = 'names:setup-workspace';
|
|
|
|
protected $description = 'Create Lethean CIC workspace, admin user, and namespace';
|
|
|
|
public function handle(): int
|
|
{
|
|
// Create workspace
|
|
$ws = \Illuminate\Support\Facades\DB::table('workspaces')->updateOrInsert(
|
|
['slug' => 'lethean'],
|
|
[
|
|
'name' => 'Lethean CIC',
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]
|
|
);
|
|
$wsId = \Illuminate\Support\Facades\DB::table('workspaces')->where('slug', 'lethean')->value('id');
|
|
$this->info("Workspace: Lethean CIC (id: {$wsId})");
|
|
|
|
// Create admin user
|
|
\Illuminate\Support\Facades\DB::table('users')->updateOrInsert(
|
|
['email' => 'developers@lethean.io'],
|
|
[
|
|
'name' => 'Charon',
|
|
'password' => bcrypt('changeme'),
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]
|
|
);
|
|
$userId = \Illuminate\Support\Facades\DB::table('users')->where('email', 'developers@lethean.io')->value('id');
|
|
$this->info("User: Charon (id: {$userId})");
|
|
|
|
// Attach to workspace
|
|
\Illuminate\Support\Facades\DB::table('user_workspace')->updateOrInsert(
|
|
['user_id' => $userId, 'workspace_id' => $wsId],
|
|
['role' => 'admin', 'joined_at' => now()]
|
|
);
|
|
$this->info('Attached to workspace as admin');
|
|
|
|
// Create namespace
|
|
\Illuminate\Support\Facades\DB::table('namespaces')->updateOrInsert(
|
|
['slug' => 'lethean-registrar'],
|
|
[
|
|
'name' => 'Lethean Registrar',
|
|
'uuid' => Str::uuid()->toString(),
|
|
'owner_type' => 'Core\\Tenant\\Models\\Workspace',
|
|
'owner_id' => $wsId,
|
|
'workspace_id' => $wsId,
|
|
'is_default' => true,
|
|
'is_active' => true,
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]
|
|
);
|
|
$this->info('Namespace: Lethean Registrar');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|