Closed tuxfamily closed 5 years ago
This is great. A few things:
env()
directly in the code, since this will fail if you use config caching. See https://laravel.com/docs/5.7/configuration#configuration-cachingOffhand, I'm not sure, but I think you can get the prefix via:
$prefix = (new Tag())->getConnection()->getTablePrefix();
The other option would be to re-write those queries in Eloquent or QueryBuilder, I suppose.
I find it weird that you'd need to change the morphedBy/ToMany()
calls in src/Models/Tag.php
and src/Taggable.php
. Doesn't Laravel automagically apply the table prefix here? If not, that sounds like an issue with Laravel.
Any chance you can add some tests for this?
Thanks again!
@tuxfamily Feel free to try the 3.5.0 version (for Laravel 5.8). I re-wrote some of your PR but I think it solves your issue now.
Hello.
The migration script does care of the table prefix, so tables are well created using the prefix, but next, in eloquent-taggable the tables names are hardcoded in the queries, so it leads to some "table not found" exceptions.
So I added support of table prefix through the env('DB_TABLE_PREFIX'). There is maybe a better way to do it, but this one "just works".
Hope it can help. Cédric.