Laravel Voyager:调用未定义的方法TCG \ Voyager \ getCoordinates()

时间:2020-08-03 17:29:18

标签: php laravel voyager

我在扩展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

1 个答案:

答案 0 :(得分:0)

use中不能包含两行。这应该可以解决问题。

class User extends \TCG\Voyager\Models\User
{
    use Notifiable, Spatial;
    ...