术语表:
- term_id(术语ID)
- name(名称)
- slug(别名)
术语分类表:
- term_taxonomy_id(术语分类ID)
- term_id(术语ID)
- description(描述)
我的术语模型:
public function TermTaxonomy(){
return $this->hasOne('TermTaxonomy');
}
我的TermTaxonomy模型:
public function Term(){
return $this->belongsTo('Term');
}
我的分类控制器:
public function update($id){
echo "$id"; // echo success
echo $data['name']; // it should update name field in term table
echo $data['slug']; // it should update slug field in term table
echo $data['TermTaxonomy']['description']; // it should update description field in termtaxonomy table
}
我该如何更新一对一关系?也许可以使用push()函数。
谢谢,抱歉我是laravel的新手。