@@ 520-540 (lines=21) @@ | ||
517 | * |
|
518 | * @return bool |
|
519 | */ |
|
520 | protected function saveTranslations() |
|
521 | { |
|
522 | $saved = true; |
|
523 | ||
524 | foreach ($this->translations as $translation) { |
|
525 | ||
526 | $translation->setRelation('parent', $this); |
|
527 | ||
528 | /* @var EloquentModel $translation */ |
|
529 | if ($saved && $this->isTranslationDirty($translation)) { |
|
530 | ||
531 | $translation->setAttribute($this->getRelationKey(), $this->getKey()); |
|
532 | ||
533 | $saved = $translation->save(); |
|
534 | } |
|
535 | } |
|
536 | ||
537 | $this->finishSave([]); |
|
538 | ||
539 | return $saved; |
|
540 | } |
|
541 | ||
542 | protected function getTranslationOrNew($locale) |
|
543 | { |
|
@@ 604-619 (lines=16) @@ | ||
601 | return count($dirtyAttributes) > 0; |
|
602 | } |
|
603 | ||
604 | public function getNewTranslation($locale) |
|
605 | { |
|
606 | $modelName = $this->getTranslationModelName(); |
|
607 | ||
608 | /* @var EloquentModel $translation */ |
|
609 | $translation = new $modelName; |
|
610 | ||
611 | $translation->setRelation('parent', $this); |
|
612 | ||
613 | $translation->setAttribute($this->getLocaleKey(), $locale); |
|
614 | $translation->setAttribute($this->getRelationKey(), $this->getKey()); |
|
615 | ||
616 | $this->translations->add($translation); |
|
617 | ||
618 | return $translation; |
|
619 | } |
|
620 | ||
621 | public function scopeTranslatedIn(Builder $query, $locale) |
|
622 | { |