mtolhuys / laravel-schematics

A Laravel package making a diagram of your models, relations and the ability to build them with it
MIT License
1.49k stars 133 forks source link

Table prefix issue #44

Open SabatinoMasala opened 4 years ago

SabatinoMasala commented 4 years ago

The table name returned by $model->getTable() is unprefixed, causing errors on the describe query if a table prefix is present.

https://github.com/mtolhuys/laravel-schematics/blob/c69a2e85687443c691ed8bd79d88d2f61eafc0b1/src/Http/Controllers/ModelsController.php#L59

https://github.com/mtolhuys/laravel-schematics/blob/c69a2e85687443c691ed8bd79d88d2f61eafc0b1/src/Http/Controllers/ModelsController.php#L60

This could be solved by adding the prefix manually:

$safeTableName = \DB::getQueryGrammar()->wrap($model->getConnection()->getTablePrefix() . $table);

I had this issue occur on an older Laravel version: 5.7

Not tested on anything newer.

mtolhuys commented 4 years ago

Hi @SabatinoMasala,

Thnx for the suggestion! I'll try it out in my environments and take it along with the next release.