Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #11 from koenhoeijmakers/fix-issue-10
Browse files Browse the repository at this point in the history
Fixes #10
  • Loading branch information
koenhoeijmakers authored Jan 25, 2019
2 parents 1faa7e9 + de1c6d7 commit 279a40a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Scopes/JoinTranslationScope.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace KoenHoeijmakers\LaravelTranslatable\Scopes;

Expand All @@ -23,6 +25,6 @@ public function apply(Builder $builder, Model $model)
$model->getTable() . '.' . $model->getKeyName(),
$model->getTranslationTable() . '.' . $model->getForeignKey()
)->where($model->getLocaleKeyName(), $model->getLocale());
})->select($model->getTable() . '.*', ...$model->formatTranslatableColumnsForSelect());
})->addSelect($model->getTable() . '.*', ...$model->formatTranslatableColumnsForSelect());
}
}
12 changes: 12 additions & 0 deletions tests/Feature/TranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@ public function testCanOverrideLocaleKey()

$this->assertEquals('lang', $model->getLocaleKeyName());
}

public function testCanAddSelect()
{
/** @var \KoenHoeijmakers\LaravelTranslatable\Tests\Feature\TestModel $model */
$model = TestModel::query()->create([
'name' => 'Monkey',
]);

$result = TestModel::query()->select('test_model_translations.id AS translation_id')->first();

$this->assertEquals($model->getTranslation('en')->getKey(), $result->translation_id);
}
}

class TestModel extends Model
Expand Down

0 comments on commit 279a40a

Please sign in to comment.