Laravel-Administrator 的关联表查询怎么用啊
看了文档说,用法如下
'user_name' => [
// 'title' => "Author",
// 'relationship' => 'user', //this is the name of the Eloquent relationship method!
// 'select' => "(:table).name",
// ],
我写的代码如下:
'user_id' => [
'title' => '作者',
'relationship' => 'users', //this is the name of the Eloquent relationship method!
'select' => "(:table).name",
],
我要在topics里靠user_id查对应的users表里的id=user_id的name字段的值
但是我写以后,就是http500报错,有几个问题:
- relationship 是不是关联表的名称??
- (:table)要不是改成关联表的名称??
- (:table).name里的
name
是不是管理表的字段???
注:各种belongsTo hasMany应该是正确的,因为前端是能查出我想要的东西的
推荐文章: