I have morph relation between posts pages and tags table.
Posts
id
othercolumn
Pages
id
othercolumn
tags
id
othercolumn
tagable_id
tagable_type
Example: i want add post to posts table and tag to tags table at same time
DB::transaction(function(){
$post = new Post;
$post->othercolumn = Input::get('something');
$tags = new Tag;
$tag->othercolumn = Input::get('something');
// here function to store post and tag
if( //post or tag not created )
{
throw new \Exception('Failed to create post or tag');
}
});
if i use function save morph relation like $post->tagable()->save($tag). will show error tagable_id cannot be null.