-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #519 from anjooficial/patch-1
Add new command of list registered.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |