laravel-mysql-spatial
laravel-mysql-spatial copied to clipboard
Method Grimzy\LaravelMysqlSpatial\Eloquent\BaseBuilder::getForeignKeyName does not exist.
Try to use this with another Library to generate ER Diagrams based off my models https://github.com/beyondcode/laravel-er-diagram-generator and have debugged to catch the following Exception
BadMethodCallException {#8003 #message: "Method Grimzy\LaravelMysqlSpatial\Eloquent\BaseBuilder::getForeignKeyName does not exist." #code: 0 #file: "./vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php" #line: 2816 trace: { ./vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2816 { …} ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1286 { …} ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php:369 { …} ./vendor/beyondcode/laravel-er-diagram-generator/src/RelationFinder.php:85 { …} ./vendor/beyondcode/laravel-er-diagram-generator/src/RelationFinder.php:39 { …} BeyondCode\ErdGenerator\RelationFinder->BeyondCode\ErdGenerator\{closure}() {} ./vendor/laravel/framework/src/Illuminate/Support/Collection.php:932 { …} ./vendor/beyondcode/laravel-er-diagram-generator/src/RelationFinder.php:40 { …} ./vendor/beyondcode/laravel-er-diagram-generator/src/GenerateDiagramCommand.php:69 { …} BeyondCode\ErdGenerator\GenerateDiagramCommand->BeyondCode\ErdGenerator\{closure}() {} ./vendor/laravel/framework/src/Illuminate/Support/Collection.php:932 { …} ./vendor/laravel/framework/src/Illuminate/Support/Collection.php:1600 { …} ./vendor/beyondcode/laravel-er-diagram-generator/src/GenerateDiagramCommand.php:71 { …} BeyondCode\ErdGenerator\GenerateDiagramCommand->handle() {} ./vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 { …} ./vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 { …} ./vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 { …} ./vendor/laravel/framework/src/Illuminate/Container/Container.php:564 { …} ./vendor/laravel/framework/src/Illuminate/Console/Command.php:179 { …} ./vendor/symfony/console/Command/Command.php:255 { …} ./vendor/laravel/framework/src/Illuminate/Console/Command.php:166 { …} ./vendor/symfony/console/Application.php:908 { …} ./vendor/symfony/console/Application.php:269 { …} ./vendor/symfony/console/Application.php:145 { …} ./vendor/laravel/framework/src/Illuminate/Console/Application.php:89 { …} ./vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:122 { …} ./artisan:37 { › $input = new Symfony\Component\Console\Input\ArgvInput, › new Symfony\Component\Console\Output\ConsoleOutput › ); arguments: { $input: Symfony\Component\Console\Input\ArgvInput {#25 …} $output: Symfony\Component\Console\Output\ConsoleOutput {#23 …} } } } }
Hoping for a fix
Are you still having this issue? If so please provide the versions of Laravel and of Laravel MySQL Spatial.
At first glance it's not related to the Laravel MySQL Spatial package.
I have a quite similar issue giving me the following message:
Undefined property: Grimzy\LaravelMysqlSpatial\Eloquent\BaseBuilder::$concats
I suspect it expects a function to be there from Eloquent's Builder Class that is not there I am using plugin version: 2.2.1 with Laravel: 6.2
Managed to figure out the issue, this was due to OctoberCMS using a custom Query Builder that extends Builder and SpacialTrait bypassing it using the Builder directly.
To resolve the issue I have created a copy of SpacialTrait and updated \Illuminate\Database\Query\Builder with October\Rain\Database\Builder
It would be nice if plugin could identify the correct query builder of the model instead.
Managed to figure out the issue, this was due to OctoberCMS using a custom Query Builder that extends Builder and SpacialTrait bypassing it using the Builder directly.
To resolve the issue I have created a copy of SpacialTrait and updated \Illuminate\Database\Query\Builder with October\Rain\Database\Builder
It would be nice if plugin could identify the correct query builder of the model instead.
Hi paishin! I'm facing the same issue with $concats. Can you please post the code of your custom SpatialTrait?
Now I don't understand how you can easily replace \Illuminate\Database\Query\Builder by October\Rain\Database\Builder because October\Rain\Database\Builder extends Illuminate\Database\Eloquent\Builder not \Illuminate\Database\Query\Builder. Clearly missing something out.
Figured out. Thanks for good advice @paishin !
use October\Rain\Database\QueryBuilder;
use October\Rain\Database\Builder as OctoberBuilder;
protected function newBaseQueryBuilder()
{
$connection = $this->getConnection();
return new QueryBuilder( // instead of BaseBuilder
$connection,
$connection->getQueryGrammar(),
$connection->getPostProcessor()
);
}
public function newEloquentBuilder($query)
{
return new OctoberBuilder($query);// instead of EloquentBuilder. Not sure if it's necessary but it seems to make sense.
}