【发布时间】:2019-04-03 15:29:30
【问题描述】:
我已经在 Laravel Nova 上的 Google 和 GitHub 问题上对此问题进行了长期调查。
我确实有下一个代码,如下所述:
/**
* @var array
*/
private $parentClasses = [
'activity' => Activity::class,
'movie' => PlayTogether::class,
'book' => Book::class
];
/**
* Returns a parent class/entity to which Skills are described
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo|Activity|PlayTogether|Book
*/
public function parent()
{
return $this->belongsTo($this->parentClasses[$this->attributes['type']], 'entity_id', 'id');
}
在记录 $this->attributes['type'] 时,我得到一个空字符串。
我该如何解决这个问题?有什么想法吗?
【问题讨论】:
标签: laravel laravel-5.6 laravel-nova