Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 如何添加数据库中不可用的字段?_Laravel_Backpack For Laravel - Fatal编程技术网

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']

在此处找到文档中的所有内容: