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

RonasIT / laravel-helpers / 12489544920

25 Dec 2024 04:53AM UTC coverage: 78.401% (+0.02%) from 78.385%
12489544920

Pull #168

github

web-flow
Merge a36445178 into 338a94856
Pull Request #168: #140 global export mode not affect for email testing

2 of 2 new or added lines in 1 file covered. (100.0%)

1020 of 1301 relevant lines covered (78.4%)

11.92 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

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,
×
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