29 lines
734 B
PHP
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'
|
|
])
|
|
);
|
|
}
|
|
}
|