Created
July 3, 2017 10:47
-
-
Save endihunter/bf9ea0f8a8855d270a4ba161850373e2 to your computer and use it in GitHub Desktop.
translatable + stapler conflict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use HasTranslations, EloquentTrait { | |
HasTranslations::getAttribute as getTranslatedAttribute; | |
HasTranslations::setAttribute as setTranslatedAttribute; | |
EloquentTrait::getAttribute as getStaplerableAttribute; | |
EloquentTrait::setAttribute as setStaplerableAttribute; | |
} | |
public function getAttribute($key) | |
{ | |
if ($this->isKeyReturningTranslationText($key)) { | |
return $this->getTranslatedAttribute($key); | |
} else { | |
if (array_key_exists($key, $this->attachedFiles)) { | |
return $this->getStaplerableAttribute($key); | |
} | |
} | |
return parent::getAttribute($key); | |
} | |
public function setAttribute($key, $value) | |
{ | |
if ($this->hasTranslatedAttributes() && in_array($key, $this->translatedAttributes)) { | |
return $this->setTranslatedAttribute($key, $value); | |
} else { | |
if (array_key_exists($key, $this->attachedFiles)) { | |
return $this->setStaplerableAttribute($key, $value); | |
} | |
} | |
return parent::setAttribute($key, $value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment