as offical documentation says :
Sometimes you may wish to save not only a model, but also all of its relationships. To do so, you may use the push method: Saving A Model And Relationships $user->push();
Terms table:
- term_id
- name
- slug
Term_taxonomy table:
- term_taxonomy_id
- term_id
- description
My Term model:
public function TermTaxonomy(){
return $this->hasOne('TermTaxonomy');
}
My TermTaxonomy model:
public function Term(){
return $this->belongsTo('Term');
}
my CategoriesController
public function store(){
$data = Input::all();
$category = new Term;
$category->name = $data['name'];
$category->slug = $data['slug'];
$category->TermTaxonomy()->taxonomy = 'category';
$category->TermTaxonomy()->description = $data['TermTaxonomy']['description'];
$category->push();
}
with my code above, I can save name and slug, but taxonomy and description not inserted. how i can do it with push() instead of save() ? is it possible ?
Thanks, i am new in Laravel.