Code Duplication    Length = 16-21 lines in 2 locations

src/Model/EloquentModel.php 2 locations

@@ 498-518 (lines=21) @@
495
     *
496
     * @return bool
497
     */
498
    protected function saveTranslations()
499
    {
500
        $saved = true;
501
502
        foreach ($this->translations as $translation) {
503
504
            $translation->setRelation('parent', $this);
505
506
            /* @var EloquentModel $translation */
507
            if ($saved && $this->isTranslationDirty($translation)) {
508
509
                $translation->setAttribute($this->getRelationKey(), $this->getKey());
510
511
                $saved = $translation->save();
512
            }
513
        }
514
515
        $this->finishSave([]);
516
517
        return $saved;
518
    }
519
520
    protected function getTranslationOrNew($locale)
521
    {
@@ 582-597 (lines=16) @@
579
        return count($dirtyAttributes) > 0;
580
    }
581
582
    public function getNewTranslation($locale)
583
    {
584
        $modelName = $this->getTranslationModelName();
585
586
        /* @var EloquentModel $translation */
587
        $translation = new $modelName;
588
589
        $translation->setRelation('parent', $this);
590
591
        $translation->setAttribute($this->getLocaleKey(), $locale);
592
        $translation->setAttribute($this->getRelationKey(), $this->getKey());
593
594
        $this->translations->add($translation);
595
596
        return $translation;
597
    }
598
599
    public function scopeTranslatedIn(Builder $query, $locale)
600
    {