Illuminate\Database\Query\Builder::updateOrInsert PHP Method

updateOrInsert() public method

Insert or update a record matching the attributes, and fill it with values.
public updateOrInsert ( array $attributes, array $values = [] ) : boolean
$attributes array
$values array
return boolean
    public function updateOrInsert(array $attributes, array $values = [])
    {
        if (!$this->where($attributes)->exists()) {
            return $this->insert(array_merge($attributes, $values));
        }
        return (bool) $this->take(1)->update($values);
    }

Usage Example

Exemplo n.º 1
-1
 /**
  * Insert or update a record matching the attributes, and fill it with values.
  *
  * @param array $attributes
  * @param array $values
  * @return bool 
  * @static 
  */
 public static function updateOrInsert($attributes, $values = array())
 {
     return \Illuminate\Database\Query\Builder::updateOrInsert($attributes, $values);
 }