Skip to content

Commit

Permalink
Fix Provider must not be accessed error (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
cable8mm authored Jan 4, 2025
1 parent f88423c commit 79b69cd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Command/GenerateNovaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/Laravel/Commands/GenerateNovaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
Expand Down
23 changes: 23 additions & 0 deletions tests/Laravel/Commands/GenerateNovaCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Cable8mm\Xeed\Tests\Laravel\Commands;

class GenerateNovaCommandTest extends \Orchestra\Testbench\TestCase
{
public function test_execute_xeed_database_command()
{
$this->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',
];
}
}

0 comments on commit 79b69cd

Please sign in to comment.