2016-11-11 24 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