我在扩展Voyager模型的模型中将字段location
定义为Spatial。但是我不断收到BadMethodCallException
Call to undefined method TCG\Voyager\Models\User::getCoordinates()
当我尝试访问BREAD时。
这是模型:
<?php
namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use TCG\Voyager\Traits\Spatial;
class User extends \TCG\Voyager\Models\User
{
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
答案 0 :(得分:0)
use
中不能包含两行。这应该可以解决问题。
class User extends \TCG\Voyager\Models\User
{
use Notifiable, Spatial;
...