push() public method

Save the model and all of its relationships.
public push ( ) : boolean
return boolean
示例#1
0
 /**
  * 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();
 }
示例#2
0
 /**
  * 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();
 }
示例#3
0
 /**
  * @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();
 }
示例#4
0
 public function push(Model $data)
 {
     $data->push();
 }