Eloquent Query builder breaks with custom relationships when using SpatialTrait
striderwhitepderas opened this issue · 0 comments
striderwhitepderas commented
MySql 5.7.31
Laravel: 6.18.39
"grimzy/laravel-mysql-spatial": "^2.0",
My model uses the SpatialTrait and defines a custom relationship packages
class Zone extends Model
{
use SpatialTrait;
// Some custom relationship
public function packages()
{
return $this->belongsToMany(\App\Models\Package::class);
}
}
Now I run some arbritary query using the relationship
$z = Zone::where('id', $zoneId)->packages()->get();
Now I cannot use any of these relationships (it seems the eloquent "builder" is being overwritten?"
message: "Call to undefined method Grimzy\LaravelMysqlSpatial\Eloquent\Builder::packages()"
This happens for any other custom relationships, although I am able to use with on the relationships, just not using the query builder. Otherwise the package works great.