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

RonasIT / laravel-helpers / 9734992282

30 Jun 2024 09:13PM UTC coverage: 77.982% (+1.6%) from 76.409%
9734992282

Pull #129

github

web-flow
Merge 1c709efb3 into 22620f288
Pull Request #129: Fix codestyle and legacy code

51 of 58 new or added lines in 10 files covered. (87.93%)

32 existing lines in 3 files now uncovered.

974 of 1249 relevant lines covered (77.98%)

14.47 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

© 2026 Coveralls, Inc