Get the first record matching the attributes or instantiate it.
public static firstOrNew ( array $attributes ) : |
||
$attributes | array | |
return |
/** * Update or Insert if not exists store_key * * @param $key * @param $value * @return bool */ public static function storePut($key, $value) { $table = parent::firstOrNew(array(self::$storeColumn['key'] => $key)); $table->{self::$storeColumn['key']} = $key; $table->{self::$storeColumn['value']} = $value; return $table->save(); }
/** * Overrided firstOrNew method of Model to trim data * * @return object */ public static function firstOrNew(array $data = array()) { $trimedData = self::trimData($data); return parent::firstOrNew($trimedData); }