41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Console\Commands\Mapledeploy;
|
||
|
|
|
||
|
|
use App\Models\User;
|
||
|
|
use Illuminate\Console\Command;
|
||
|
|
|
||
|
|
class UserList extends Command
|
||
|
|
{
|
||
|
|
protected $signature = 'mapledeploy:user:list';
|
||
|
|
|
||
|
|
protected $description = 'List Coolify users for MapleDeploy dashboard access management';
|
||
|
|
|
||
|
|
public function handle(): int
|
||
|
|
{
|
||
|
|
$users = User::with('teams')
|
||
|
|
->orderBy('id')
|
||
|
|
->get()
|
||
|
|
->map(fn (User $user) => [
|
||
|
|
'id' => $user->id,
|
||
|
|
'email' => $user->email,
|
||
|
|
'name' => $user->name,
|
||
|
|
'created_at' => $user->created_at?->toISOString(),
|
||
|
|
'teams' => $user->teams
|
||
|
|
->map(fn ($team) => [
|
||
|
|
'id' => $team->id,
|
||
|
|
'name' => $team->name,
|
||
|
|
'role' => $team->pivot?->role,
|
||
|
|
])
|
||
|
|
->values()
|
||
|
|
->all(),
|
||
|
|
])
|
||
|
|
->values()
|
||
|
|
->all();
|
||
|
|
|
||
|
|
$this->line(json_encode(['users' => $users], JSON_THROW_ON_ERROR));
|
||
|
|
|
||
|
|
return self::SUCCESS;
|
||
|
|
}
|
||
|
|
}
|