Skip to content

Commit 0f9b1d7

Browse files
authored
Merge pull request #131 from openclassify/emrullahardc-patch-3
Update AdvObserver.php
2 parents 872e110 + 0d03e8d commit 0f9b1d7

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

src/Adv/AdvObserver.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,21 @@ class AdvObserver extends EntryObserver
1212
{
1313
private function translateFixer($entryId)
1414
{
15-
//TODO:: Use single query
16-
$defaultLocale = setting_value('streams::default_locale');
17-
$translations = DB::table('advs_advs_translations')
18-
->select(['locale', 'name'])
15+
16+
//TODO TEMP LANG FIX WITH FATIH.
17+
$transCount = DB::table('advs_advs_translations')
18+
->select('id')
19+
->whereNull('name')
1920
->where('entry_id', $entryId)
20-
->whereNotNull('locale')
21-
->get();
21+
->count();
2222

23-
if ($translations) {
24-
$name = "";
25-
foreach ($translations as $translation) {
26-
if ($translation->locale == $defaultLocale && !empty($translation->name)) {
27-
$name = $translation->name;
28-
break;
29-
} else if (!empty($translation->name)) {
30-
$name = $translation->name;
31-
}
32-
}
3323

24+
if ($transCount > 1) {
3425
DB::table('advs_advs_translations')
3526
->whereNull('name')
3627
->where('entry_id', $entryId)
37-
->update(['name' => $name]);
28+
->delete();
3829
}
39-
4030
}
4131

4232
public function created(EntryInterface $entry)

0 commit comments

Comments
 (0)