我有一个国家和一个大陆的表。这些国家有一个“大陆id”字段。国家模式有一种方法:
public function getContinent()
{
return $this->belongsTo('App\Models\Continent','continent_id','id');
}
如果我用tinker测试一下,我会得到正确的答案:
$co = App\Models\Country::with('getContinent)->first()
在CountryCrudController上的设置中,我想添加一个显示大陆的字段,并且我还想将7个大陆中的一个选择添加到国家编辑中,因此在列表部分我定义了:
$this->crud->addColumn([
'name' => "continent",
'label' => "continent", // Table column heading
'type' => "select",
'entity' => 'getContinent ', // the method in your Model
'attribute' => 'continent',
]);
但当我试着运行它时,我得到:
请问我做错了什么?