Subject: Save / Persist model with relationship
Hi,wanted to know how to save a model and it's relationships ?
Ex:
$u = User:find(1);
$post = new Post();$post->title = "A title";
// something like this ?$post->user->insert($u);$post->save();
// instead of the manual $post->user_id = $u->id;
// or perhaps something like below$user->post[] = $post;$user->save();
anyone knows if it exists in the doc or if there's a fork ?
June 27 2010
February 28, 2013
Subject: Save / Persist model with relationship
Hi,
wanted to know how to save a model and it's relationships ?
Ex:
$u = User:find(1);
$post = new Post();
$post->title = "A title";
// something like this ?
$post->user->insert($u);
$post->save();
// instead of the manual
$post->user_id = $u->id;
// or perhaps something like below
$user->post[] = $post;
$user->save();
anyone knows if it exists in the doc or if there's a fork ?