sebastienheyd / boilerplate

Laravel AdminLTE 3 Boilerplate package with blade components, users, roles and permissions management
MIT License
208 stars 63 forks source link

Problem with Laravel 11 and generateDatatable command #97

Closed maiga-soluciones closed 2 weeks ago

maiga-soluciones commented 3 weeks ago

When trying to run the generate datatable, the followin error appears:

Model structure is not accessible in the database

This is trigerred by the following exception:

Method Illuminate\Database\MySqlConnection::getDoctrineColumn does not exist.
BadMethodCallException: Method Illuminate\Database\MySqlConnection::getDoctrineColumn does not exist. in /app/vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:115
Stack trace:
#0 /app/vendor/sebastienheyd/boilerplate/src/Console/Datatable.php(122): Illuminate\Database\Connection->__call('getDoctrineColu...', Array)
#1 /app/vendor/sebastienheyd/boilerplate/src/Console/Datatable.php(71): Sebastienheyd\Boilerplate\Console\Datatable->generateColumnsForModel(Object(App\Models\Paises))
#2 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Sebastienheyd\Boilerplate\Console\Datatable->handle()
#3 /app/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#4 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#5 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#6 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(690): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#7 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(213): Illuminate\Container\Container->call(Array)
#8 /app/vendor/symfony/console/Command/Command.php(279): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#9 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#10 /app/vendor/symfony/console/Application.php(1047): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /app/vendor/symfony/console/Application.php(316): Symfony\Component\Console\Application->doRunCommand(Object(Sebastienheyd\Boilerplate\Console\Datatable), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /app/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(197): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1203): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /app/artisan(13): Illuminate\Foundation\Application->handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))
#16 {main}
sebastienheyd commented 3 weeks ago

Hi, it seems that the table linked to your model does not exists in the db, have you used the --nodb option when generating the datatable ?

See the documentation :

Defining a model as data source will automatically scan the database to define the visible fields as datatable columns. You can avoid this scan by using the --nodb option, in this case the generator will only use the fields declared in the model class.

sebastienheyd commented 3 weeks ago

However, I should take into account the exception if no table is found to display a more meaningful message. I'll make a note of it for future development.

maiga-soluciones commented 3 weeks ago

Hi sebastienheyd:

The table contains data and the model is valid.

I'll send a MR with the change done to fix this issue, as I did a modification to make this work.