2016-11-11 65 views
0

我有一个自定义字段的模型,我想绑定基本模型扩展的所有模型的配置详细信息! 我CoctomFormBulder型号如何将模型数据绑定到Laravel的所有子模型

class CustomFormBuilder extends \Eloquent 
{ 
    protected $fillable = []; 

    protected $table = 'custom_fields_configure'; 
} 

这里是我的基本模型,我现在已经尝试最多。

class BaseModel extends \Eloquent { 

    protected $guarded = array('q'); 

    protected $table  = 'custom_fields_configure'; 

    protected $appends = ['configure']; 

    public function getConfigerAttribute() { 

     if (isset($this->attributes['configure'])) { 
     //return URL::asset($this->attributes['image']); 
     return $this->attributes['configure']; 
     } 
    return ''; 
    } 


    public function setConfigerAttribute($configure) { 
     $this->attributes['configure'] = $configure; 
    } 
} 

如何从CustomFormBuilder数据绑定到我的所有车型中的应用

回答

0

就让这需要一个逻辑扩展“CustomFormBuilder”类

+0

在我的应用程序有50款以上的车型,使更改可能会破坏应用程序,我只需要从Basemodel –

+0

推送数据也许这是一个选项: – Snaterj