diff --git a/src/Command/GenerateNovaCommand.php b/src/Command/GenerateNovaCommand.php index 56fbf6e..331e94d 100644 --- a/src/Command/GenerateNovaCommand.php +++ b/src/Command/GenerateNovaCommand.php @@ -61,6 +61,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int ? Xeed::getInstance()->attach()->getTables() : Xeed::getInstance()->attach($table)->getTables(); + $tables = array_filter($tables, function ($table) { + return ! in_array($table, Xeed::LARAVEL_DEFAULT_TABLES); + }); + foreach ($tables as $table) { try { NovaResourceGenerator::make($table)->run(force: $force); diff --git a/src/Laravel/Commands/GenerateNovaCommand.php b/src/Laravel/Commands/GenerateNovaCommand.php index 3ee6e5e..078ae7f 100644 --- a/src/Laravel/Commands/GenerateNovaCommand.php +++ b/src/Laravel/Commands/GenerateNovaCommand.php @@ -5,6 +5,7 @@ use Cable8mm\Xeed\Generators\NovaResourceGenerator; use Cable8mm\Xeed\Xeed; use Illuminate\Console\Command; +use Illuminate\Support\Facades\DB; class GenerateNovaCommand extends Command { @@ -34,8 +35,8 @@ public function handle(Xeed $xeed) $table = $this->option('table'); $tables = is_null($table) - ? Xeed::getInstance()->attach()->getTables() - : Xeed::getInstance()->attach($table)->getTables(); + ? $xeed->addPdo(DB::connection()->getPDO())->attach()->getTables() + : $xeed->addPdo(DB::connection()->getPDO())->attach($table)->getTables(); $tables = array_filter($tables, function ($table) { return ! in_array($table, Xeed::LARAVEL_DEFAULT_TABLES); diff --git a/tests/Laravel/Commands/GenerateNovaCommandTest.php b/tests/Laravel/Commands/GenerateNovaCommandTest.php new file mode 100644 index 0000000..a3afbb3 --- /dev/null +++ b/tests/Laravel/Commands/GenerateNovaCommandTest.php @@ -0,0 +1,23 @@ +artisan('xeed:nova')->assertSuccessful(); + } + + public function test_execute_xeed_database_command_with_table() + { + $this->artisan('xeed:nova')->assertSuccessful(); + } + + protected function getPackageProviders($app) + { + return [ + 'Cable8mm\Xeed\Laravel\XeedServiceProvider', + ]; + } +}