/**
  * Adds meta data
  *
  * @return mixed
  */
 public function addMeta($key, $value)
 {
     $existing = $this->meta()->where('key', $key)->where('value', Helpers::maybeEncode($value))->first();
     if ($existing) {
         return false;
     }
     $meta = $this->meta()->create(['key' => $key, 'value' => $value]);
     return $meta->isSaved() ? $meta : $meta->getErrors();
 }
Exemple #2
0
 /**
  * Maybe encode a value for saving
  *
  * @return null
  */
 public function setValueAttribute($value)
 {
     $this->attributes['value'] = Helpers::maybeEncode($value);
 }