我在扩展Voyager模型的模型中将字段location
定义为Spatial。但我一直在拿BadMethodCallException
Call to undefined method TCGVoyagerModelsUser::getCoordinates()
当我尝试访问BREAD时。
这是型号:
<?php
namespace App;
use IlluminateContractsAuthMustVerifyEmail;
use IlluminateFoundationAuthUser as Authenticatable;
use IlluminateNotificationsNotifiable;
use TCGVoyagerTraitsSpatial;
class User extends TCGVoyagerModelsUser
{
use Notifiable;
use Spatial;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
/**
* Map Coordinate fields
*/
protected $spatial = [
'location'
];
}
我还尝试在模式中将位置列设置为类型GEOMETRY和POINT。但我怀疑这与此无关。
我正在使用Laravel 7和Voyager 1.4
use
不能有两行。这应该能解决问题。
class User extends TCGVoyagerModelsUser
{
use Notifiable, Spatial;
...