39 lines
840 B
PHP
39 lines
840 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Console\Command;
|
|
|
|
class ShowUsers extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'show:users {page=1}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Show all users';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
$page = (int) $this->argument('page');
|
|
$users = User::all()->forPage($page, 20)->all();
|
|
|
|
$this->info("Listing all users for page $page");
|
|
$this->info("Id\tName\tBalance");
|
|
foreach ($users as $user) {
|
|
$this->info($user->id . ":\t" . $user->name . "\t" . $user->balance);
|
|
}
|
|
}
|
|
}
|