/** * Append one or more values to an array. * * @return mixed */ public function push() { if ($parameters = func_get_args()) { $unique = false; if (count($parameters) == 3) { list($column, $values, $unique) = $parameters; } else { list($column, $values) = $parameters; } // Do batch push by default. if (!is_array($values)) { $values = [$values]; } $query = $this->setKeysForSaveQuery($this->newQuery()); $this->pushAttributeValues($column, $values, $unique); return $query->push($column, $values, $unique); } return parent::push(); }
/** * Iterates through the relations, associates each object with the model, and save them into the database. * * @param \Illuminate\Database\Eloquent\Model $model The model object to associate * @param array $relations The instances to be associated * @return bool True if the model is successfully persisted into the database */ public function relate($model, $relations = []) { foreach ($relations as $relate => $object) { if (isset($object)) { $model->{$relate}()->associate($object); } } $model->push(); return $model->save() && $this->cacheBust(); }
/** * @param Model $model * @param array $attributes * * @return bool */ public function update(Model $model, array $attributes) { foreach ($attributes as $key => $value) { $model->{$key} = $value; } return $model->push(); }
public function push(Model $data) { $data->push(); }