From 7eae435a50c0cb7e822dd8f1d6634b72dfb5f472 Mon Sep 17 00:00:00 2001 From: b1ek Date: Tue, 17 Sep 2024 22:53:14 +1000 Subject: [PATCH] refactor: use builtin table function to display table --- app/Console/Commands/ShowUsers.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/ShowUsers.php b/app/Console/Commands/ShowUsers.php index 30113ab..49e86fb 100644 --- a/app/Console/Commands/ShowUsers.php +++ b/app/Console/Commands/ShowUsers.php @@ -29,10 +29,12 @@ class ShowUsers extends Command $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"); + $rows = []; foreach ($users as $user) { - $this->info($user->id . ":\t" . $user->name . "\t" . $user->balance); + array_push($rows, [$user->id, $user->name, $user->balance]); } + + $this->info("Listing all users for page $page"); + $this->table([ 'ID', 'Name', 'Balance' ], $rows); } }