Skip to content

Commit

Permalink
feat: add row count to tables output (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
innoflash authored May 2, 2020
1 parent 993552a commit de87b4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/Commands/ListColumnsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace OhSeeSoftware\LaravelSchemaList\Commands;

use Illuminate\Console\Command;
use Illuminate\Database\ConnectionResolverInterface;
use OhSeeSoftware\LaravelSchemaList\Schemas\SchemaContract;

class ListColumnsCommand extends Command
Expand Down
8 changes: 6 additions & 2 deletions src/Commands/ListTablesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace OhSeeSoftware\LaravelSchemaList\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use OhSeeSoftware\LaravelSchemaList\Schemas\SchemaContract;

class ListTablesCommand extends Command
Expand All @@ -15,12 +16,15 @@ class ListTablesCommand extends Command

public function handle(SchemaContract $schema)
{
$headers = ['Tables', 'Columns'];
$headers = ['Tables', 'Columns', 'Rows'];
$rows = $schema->getTables();

$rows = collect($rows)
->map(function ($row) use ($schema) {
return array_merge($row, [count($schema->getColumns($row[0]))]);
return array_merge($row, [
count($schema->getColumns($row[0])),
DB::table($row[0])->count(),
]);
})->toArray();

$this->table($headers, $rows);
Expand Down

0 comments on commit de87b4b

Please sign in to comment.