I have defined a field location
as Spatial in a model that extends a Voyager model. But I keep getting a BadMethodCallException
Call to undefined method TCG\Voyager\Models\User::getCoordinates()
when I try to access the BREAD.
Here is the Model:
<?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'
];
}
I have also tried setting the location column to type GEOMETRY and POINT in the schema. But I suspect that has nothing to do with this.
I'm using Laravel 7 and Voyager 1.4
You can't have two lines with use
. This should solve the problem.
class User extends \TCG\Voyager\Models\User
{
use Notifiable, Spatial;
...