From 62d1c5685476d6fd75e4c73fdad273f4288bbee1 Mon Sep 17 00:00:00 2001 From: Dimitrios Savvopoulos <ds@dimsav.com> Date: Thu, 4 Sep 2014 20:52:58 +0200 Subject: [PATCH 1/2] Translated classes answer true when asked if their translated attributes are set. --- Translatable/Translatable.php | 5 +++++ tests/TestCoreModelExtension.php | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Translatable/Translatable.php b/Translatable/Translatable.php index 95e11a65..e412dc1e 100644 --- a/Translatable/Translatable.php +++ b/Translatable/Translatable.php @@ -224,4 +224,9 @@ protected function getNewTranslationInstance($locale) return $translation; } + public function __isset($key) + { + return (in_array($key, $this->translatedAttributes) || parent::__isset($key)); + } + } diff --git a/tests/TestCoreModelExtension.php b/tests/TestCoreModelExtension.php index 35de291d..8e4b4c32 100644 --- a/tests/TestCoreModelExtension.php +++ b/tests/TestCoreModelExtension.php @@ -188,4 +188,16 @@ public function it_passes_the_N_plus_1_problem() $this->assertGreaterThan(2, count($countries)); $this->assertEquals(2, $this->queriesCount); } + + + // Forms + + /** + * @test + */ + public function it_fakes_isset_for_translated_attributes() + { + $country = Country::find(1); + $this->assertEquals(true, isset($country->name)); + } } \ No newline at end of file From 52210165ca2d1c197cc6b829abbf8f0e4ecf9253 Mon Sep 17 00:00:00 2001 From: Dimitrios Savvopoulos <ds@dimsav.com> Date: Thu, 4 Sep 2014 20:53:14 +0200 Subject: [PATCH 2/2] Updated contributing.md file. --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 66642b3c..96857520 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ ## Coding Guidelines -Translatable follows the [coding guidelines](https://github.com/laravel/framework/blob/master/CONTRIBUTING.md#coding-guidelines) used by Laravel. - -Pull requests MUST be sent to the development branch. \ No newline at end of file +* Translatable follows the [coding guidelines](https://github.com/laravel/framework/blob/master/CONTRIBUTING.md#coding-guidelines) used by Laravel. +* Pull requests MUST be sent to the development branch. +* To preserve the quality of the package, only well tested code will by merged. \ No newline at end of file