This repository was archived by the owner on Jun 18, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 5
5
use Dimsav \Translatable \Test \Model \Country ;
6
6
use Dimsav \Translatable \Test \Model \CountryStrict ;
7
7
use Dimsav \Translatable \Test \Model \CountryWithCustomLocaleKey ;
8
+ use Dimsav \Translatable \Test \Model \CountryWithCustomTranslationModel ;
8
9
9
10
class TranslatableTest extends TestsBase
10
11
{
@@ -317,6 +318,18 @@ public function test_the_locale_key_can_be_customized_per_model()
317
318
$ this ->assertEquals ($ country ->getLocaleKey (), 'language_id ' );
318
319
}
319
320
321
+ public function test_the_translation_model_can_be_customized ()
322
+ {
323
+ $ country = CountryWithCustomTranslationModel::create ([
324
+ 'code ' => 'es ' ,
325
+ 'name:en ' => 'Spain ' ,
326
+ 'name:de ' => 'Spanien ' ,
327
+ ]);
328
+ $ this ->assertTrue ($ country ->exists ());
329
+ $ this ->assertEquals ($ country ->translate ('en ' )->name , 'Spain ' );
330
+ $ this ->assertEquals ($ country ->translate ('de ' )->name , 'Spanien ' );
331
+ }
332
+
320
333
public function test_it_reads_the_configuration ()
321
334
{
322
335
$ this ->assertEquals (App::make ('config ' )->get ('translatable.translation_suffix ' ), 'Translation ' );
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ class CountryWithCustomLocaleKey extends Eloquent
11
11
12
12
public $ table = 'countries ' ;
13
13
public $ translatedAttributes = ['name ' ];
14
- public $ translationModel = 'Dimsav\Translatable\Test\Model\CountryTranslation ' ;
15
14
16
15
/*
17
16
* You can customize per model, which attribute will
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Dimsav \Translatable \Test \Model ;
4
+
5
+ use Dimsav \Translatable \Translatable ;
6
+
7
+ class CountryWithCustomTranslationModel extends Country
8
+ {
9
+ use Translatable;
10
+
11
+ public $ table = 'countries ' ;
12
+ public $ translationForeignKey = 'country_id ' ;
13
+ public $ translationModel = 'Dimsav\Translatable\Test\Model\CountryTranslation ' ;
14
+ }
You can’t perform that action at this time.
0 commit comments