首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel Voyager:调用未定义的方法TCG\Voyager\ getCoordinates()

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

Stack Overflow用户
提问于 2020-08-04 01:29:19
回答 1查看 603关注 0票数 0

我在一个扩展了Voyager模型的模型中定义了一个字段location作为空间。但我一直收到一台BadMethodCallException Call to undefined method TCG\Voyager\Models\User::getCoordinates()

当我试图拿到面包的时候。

以下是模型:

代码语言:javascript
复制
<?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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-04 01:35:42

使用use不能有两行代码。这应该可以解决问题。

代码语言:javascript
复制
class User extends \TCG\Voyager\Models\User
{
    use Notifiable, Spatial;
    ...
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63234242

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档