Backpack for laravel 搜索中的复合字段

Backpack for laravel 搜索中的复合字段,backpack-for-laravel,Backpack For Laravel,我正在尝试从相关表中获取名字和姓氏 我曾尝试在相关表上使用访问器,该访问器在加载页面和添加/编辑时工作正常,但在搜索时显示错误 未找到列:“where子句”中的1054未知列“FullName” 这个专栏显然不存在 所以我在我的相关模型中有这个 { return $this->attributes['first_name'] . ' ' . $this->attributes['last_name']; } 在我的背包积垢控制器下面 $this

我正在尝试从相关表中获取名字和姓氏

我曾尝试在相关表上使用访问器,该访问器在加载页面和添加/编辑时工作正常,但在搜索时显示错误

未找到列:“where子句”中的1054未知列“FullName”

这个专栏显然不存在

所以我在我的相关模型中有这个

    {
        return $this->attributes['first_name'] . ' ' . $this->attributes['last_name'];
    }
在我的背包积垢控制器下面

   $this->crud->addColumn([ // n-n relationship (with pivot table)
            'label' => 'Account', // Table column heading
            'type' => 'select',
            'name' => 'user_id', // the method that defines the relationship in your Model
            'entity' => 'user', // the method that defines the relationship in your Model
            'attribute' => 'FullName', // foreign key attribute that is shown to user
            'model' => "App\Models\BackpackUser", // foreign key model

        ]);

如果我犯了错误,我们将非常感谢您的意见

这需要一个真正的专栏

您可以使用视图(就像您已经做的那样)或
model\u函数
列来格式化模型类中的表格单元格值-

看看什么对你来说更简单


注意:如果排序或搜索没有按预期工作,请参见和

现在我正在使用临时解决方法,创建一个全名字段作为我在模式中引用的视图