Laravel Voyager:调用未定义的方法 TCG\Voyager\getCoordinates()
Laravel Voyager: Call to undefined method TCG\Voyager\ getCoordinates()
我在扩展 Voyager 模型的模型中将字段 location
定义为 Spatial。但我一直收到 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'
];
}
我还尝试将位置列设置为在架构中键入 GEOMETRY 和 POINT。但我怀疑这与此无关。
我正在使用 Laravel 7 和 Voyager 1.4
use
不能有两行。这应该可以解决问题。
class User extends \TCG\Voyager\Models\User
{
use Notifiable, Spatial;
...
我在扩展 Voyager 模型的模型中将字段 location
定义为 Spatial。但我一直收到 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'
];
}
我还尝试将位置列设置为在架构中键入 GEOMETRY 和 POINT。但我怀疑这与此无关。
我正在使用 Laravel 7 和 Voyager 1.4
use
不能有两行。这应该可以解决问题。
class User extends \TCG\Voyager\Models\User
{
use Notifiable, Spatial;
...