Skip to content

Commit

Permalink
Merge pull request #519 from anjooficial/patch-1
Browse files Browse the repository at this point in the history
Add new command of list registered.
  • Loading branch information
MGatner authored Jul 12, 2022
2 parents cecfbf5 + 2fe497b commit 9ab8281
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/Commands/ListUsers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php namespace Myth\Auth\Commands;

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;

class ListUsers extends BaseCommand
{
protected $group = 'Auth';
protected $name = 'auth:list_users';
protected $description = 'Lists users from the database.';
protected $usage = 'auth:list_users';

public function run(array $params)
{
$db = db_connect();

// get all groups
$rows = $db->table('users')
->select('id, username, email')
->orderBy('id', 'asc')
->get()->getResultArray();

if (empty($rows))
{
CLI::write( CLI::color("There are no users.", 'yellow') );
}
else
{
$thead = ['User ID', 'Username', 'E-Mail'];
CLI::table($rows, $thead);
}
}
}

0 comments on commit 9ab8281

Please sign in to comment.