Files
GSB-Construction/app/Console/Commands/ListUsersRolesCommand.php
Ajjj be79555bd0
Some checks failed
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
Tests / PHP 8.5 (push) Has been cancelled
feat(dashboard): rebuild role mapping, cleanup database users and obsolete seeders
2026-08-20 16:41:28 +08:00

29 lines
734 B
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
class ListUsersRolesCommand extends Command
{
protected $signature = 'users:check-roles';
protected $description = 'List all users with their types and roles';
public function handle()
{
$users = User::with('roles')->get();
$this->table(
['ID', 'Name', 'Email', 'User Type', 'Contractor ID', 'Roles'],
$users->map(fn($u) => [
$u->id,
$u->name,
$u->email,
$u->user_type,
$u->contractor_id ?? 'None',
$u->roles->pluck('name')->implode(', ') ?: 'No Roles'
])
);
}
}