}
- /**
- * Create translated items as json.
- *
- * @param array $attributes
- * @return static
- */
- public static function create(array $attributes = [])
- {
- $locale = $attributes['locale'] ?? \App::getLocale();
- $attributes = array_except($attributes, ['locale']);
- $non_translatable = [];
-
- $model = new static();
-
- // do the actual saving
- foreach ($attributes as $attribute => $value) {
- if ($model->isTranslatableAttribute($attribute)) { // the attribute is translatable
- $model->setTranslation($attribute, $locale, $value);
- } else { // the attribute is NOT translatable
- $non_translatable[$attribute] = $value;
- }
- }
- $model->fill($non_translatable)->save();
-
- return $model;
- }
-
public function getPrimaryKey()
{
return $this->primaryKey;
return $this->updateTranslations($attributes, $options);
}
+ public function create(array $attributes = [])
+ {
+ $attributes = Json::decodeRecursive($attributes, Json::TYPE_ARRAY);
+ return $this->createTranslations($attributes);
+ }
+
/**
* @param $controller CubistMagicController
*/