FOF30\Model\DataModel\Relation::saveAll PHP Method

saveAll() public method

Saves all related items. You can use it to touch items as well: every item being saved causes the modified_by and modified_on fields to be changed automatically, thanks to the DataModel's magic.
public saveAll ( )
    public function saveAll()
    {
        if ($this->data instanceof Collection) {
            foreach ($this->data as $item) {
                if ($item instanceof DataModel) {
                    $item->save();
                }
            }
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Saves all related items. For many-to-many relations there are two things we have to do:
  * 1. Save all related items; and
  * 2. Overwrite the pivot table data with the new associations
  */
 public function saveAll()
 {
     // Save all related items
     parent::saveAll();
     $this->saveRelations();
 }
All Usage Examples Of FOF30\Model\DataModel\Relation::saveAll