【发布时间】:2019-04-11 15:51:37
【问题描述】:
当关系方法名称和外键前缀不同时,属于关系在我的 Nova 应用程序中不起作用。
我有两个表,event 和 client_location 以及 Models Event 和 ClientLocation
事件模型:
class Event extends Model
{
public function clientLocation()
{
return $this->belongsTo(\App\ClientLocation::class, 'location_id');
}
}
客户端位置模型:
class ClientLocation extends Model
{
public function events()
{
return $this->hasMany(\App\Event::class, 'location_id');
}
}
Event 的 Nova Resource 字段方法:
public function fields(Request $request)
{
return [
ID::make()->sortable(),
BelongsTo::make('clientLocation'),
];
}
知道如何处理这个问题吗?
【问题讨论】:
标签: php laravel laravel-nova