public function push($data = null, $orderingFilter = '', $ignore = null, array $relations = null)
{
// Store the model's $touches definition
$touches = $this->touches;
// If $relations is non-null, remove $relations from $this->touches. Since $relations will be saved, they are
// implicitly touched. We don't want to double-touch those records, do we?
if (is_array($relations)) {
$this->touches = array_diff($this->touches, $relations);
} else {
$this->touches = array();
}
// Save this record
$this->save($data, $orderingFilter, $ignore, false);
// Push all relations specified (or all relations if $relations is null)
$relManager = $this->getRelations();
$allRelations = $relManager->getRelationNames();
if (!empty($allRelations)) {
foreach ($allRelations as $relationName) {
if (!is_null($relations) && !in_array($relationName, $relations)) {
continue;
}
$relManager->save($relationName);
}
}
// Restore the model's $touches definition
$this->touches = $touches;
// Return self for chaining
return $this;
}