After update composer , shows me "Call to undefined method Jenssegers\Mongodb\Query\Builder::getName()" after php artisan db:seed .
Laravel version: 5.4.21 - error
Laravel version: 5.4.15 - ok
I'm also getting this error in laravel 5.4.21.
It pops up when i'm using factory()->create().
A workaround is to use factory()->make() and then save all the models in a loop.
Dosen't work with factory states thought..
Quick dirty fix to get your tests to work before a proper solution is in place;
in Jenssegers\Mongodb\Eloquent\Builder.php
add
public function getName() {
return "mongodb";
}
The break happend from Laravel version 5.4.19 => 5.4.20. Unfortunately I couldn't find a quick sophisticated fix.
A better temporal solution (which doesn't involve modifying vendor files), is loading a macro into the builder.
This can be done in a service provider such as app\Providers\AppServiceProvider.php:
use Jenssegers\Mongodb\Eloquent\Builder;
...
public function register() {
Builder::macro('getName', function() {
return 'mongodb';
});
}
If you are using multiple mongo connections (eg: for different models), or use a different name for the mongo connection then the above fix needs a bit of tweaking. Try the following instead (it uses the builder's model's connection, as it should):
use Jenssegers\Mongodb\Eloquent\Builder;
...
public function register() {
Builder::macro('getName', function() {
return $this->getModel()->getConnectionName();
});
}
I believe this was fixed by #1300. Can anyone confirm?
In Lumen this problem still happening, I fixed it switching to version v3.3.0-alpha.
Hi have the same problem with Lumen is does anyone knows it is there a PR for this?
Most helpful comment
A better temporal solution (which doesn't involve modifying vendor files), is loading a macro into the builder.
This can be done in a service provider such as
app\Providers\AppServiceProvider.php: