我在一个扩展了Voyager模型的模型中定义了一个字段location作为空间。但我一直收到一台BadMethodCallException Call to undefined method TCG\Voyager\Models\User::getCoordinates()
当我试图拿到面包的时候。
以下是模型:
<?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'
];
}我还尝试将location列设置为在架构中键入GEOMETRY和POINT。但我怀疑这与此无关。
我使用的是Laravel 7和Voyager 1.4
发布于 2020-08-04 01:35:42
使用use不能有两行代码。这应该可以解决问题。
class User extends \TCG\Voyager\Models\User
{
use Notifiable, Spatial;
...https://stackoverflow.com/questions/63234242
复制相似问题