Create or update a record matching the attributes, and fill it with values.
public updateOrCreate ( array $attributes, array $values = [] ) : |
||
$attributes | array | |
$values | array | |
return |
/** * Store settings in the database. */ public function save() { if ($this->unsaved) { $all = $this->getData(); $data = array_dot($all); foreach ($data as $key => $value) { $this->options->updateOrCreate(compact('key'), compact('key', 'value')); } $this->options->whereNotIn('key', array_keys($data))->delete(); $this->unsaved = false; } }
/** * Create or update a record matching the attributes, and fill it with values. * * @param array $attributes * @param array $values * @return \Illuminate\Database\Eloquent\Model * @static */ public static function updateOrCreate($attributes, $values = array()) { return \Illuminate\Database\Eloquent\Builder::updateOrCreate($attributes, $values); }