• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

RonasIT / laravel-helpers / 10508933565

22 Aug 2024 01:20PM UTC coverage: 77.706% (-0.2%) from 77.868%
10508933565

push

github

web-flow
Merge pull request #139 from RonasIT/feat/update-dependencies

Update dependencies

9 of 16 new or added lines in 8 files covered. (56.25%)

1 existing line in 1 file now uncovered.

962 of 1238 relevant lines covered (77.71%)

11.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Traits/TranslationUpdateTrait.php
1
<?php
2

3
namespace RonasIT\Support\Traits;
4

5
use Illuminate\Support\Arr;
6

7
trait TranslationUpdateTrait
8
{
9
    public function updateWithTranslations($id, $data)
10
    {
11
        $translations = Arr::pull($data, 'translations');
×
12

13
        if (empty($translations)) {
×
14
            return $this->update(['id' => $id], $data);
×
15
        }
16

NEW
17
        $modelInstance = new $this->model();
×
18

19
        $foreignKey = $modelInstance->allTranslations()->getForeignKeyName();
×
20

21
        $translationModel = $modelInstance->getTranslationClass();
×
22

23
        foreach ($translations as $translation) {
×
24
            $translationModel::where([
×
25
                $foreignKey => $id,
×
NEW
26
                'locale' => $translation['locale'],
×
27
            ])->update($translation);
×
28
        }
29

30
        return $this->withRelations(['allTranslations'])->find($id);
×
31
    }
32
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc