Tuesday, October 21, 2014

laravel saving child model

Took me hours to finally figure this out.

When calling child has_many, calling method seems to return the association / querybuilder,
but calling attribute seems to return the collection.

so save the child record,

$object->childs()->save($child)

to get list of collection of childs, calling:

foreach($object->childs as $child)

No comments: