alex.test/app/Console/Commands/ShowUsers.php

39 lines
840 B
PHP
Raw Normal View History

2024-09-17 14:50:06 +02:00
<?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);
}
}
}