Laravel 如何添加数据库中不可用的字段?
我无法添加数据库中不可用的字段 我试着添加Laravel 如何添加数据库中不可用的字段?,laravel,backpack-for-laravel,Laravel,Backpack For Laravel,我无法添加数据库中不可用的字段 我试着添加 $this->crud->addFields([ [ 'name' => 'coupon_type', 'label' => 'Coupon For', 'type' => 'select_from_array', 'options' => [ // Options ]
$this->crud->addFields([
[
'name' => 'coupon_type',
'label' => 'Coupon For',
'type' => 'select_from_array',
'options' => [
// Options
],
'allows_null' => true,
'default' => 1,
'attributes' => [
'id' => 'coupon_type'
]
]
]);
我想在我的创建页面中添加字段。您可以通过为“虚拟”属性定义访问器来完成此操作
public function getIsAdminAttribute()
{
return $this->attributes['admin'] == 'yes';
}
并定义模型上的附录
protected$appends=['is_admin']代码>
在此处找到文档中的所有内容: