Skip to content
This repository was archived by the owner on Jun 18, 2019. It is now read-only.

Commit ace069b

Browse files
committed
Fixed: translations not saved when object not dirty. (laravel core was updated)
1 parent 6f4f544 commit ace069b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Translatable/Translatable.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,18 @@ public function setAttribute($key, $value)
105105

106106
public function save(array $options = array())
107107
{
108-
if (parent::save($options))
108+
if (count($this->getDirty()) > 0)
109+
{
110+
if (parent::save($options))
111+
{
112+
return $this->saveTranslations();
113+
}
114+
return false;
115+
}
116+
else
109117
{
110118
return $this->saveTranslations();
111119
}
112-
return false;
113120
}
114121

115122
public function fill(array $attributes)

tests/TestCoreModelExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function it_throws_query_exception_if_saving_and_name_is_null()
3838
/**
3939
* @test
4040
*/
41-
public function it_returns_false_if_save_was_not_successful()
41+
public function it_returns_false_if_parent_save_was_not_successful()
4242
{
4343
$that = $this;
4444
$event = App::make('events');
@@ -47,6 +47,7 @@ public function it_returns_false_if_save_was_not_successful()
4747
});
4848

4949
$country = Country::find(1);
50+
$country->iso = 'make_model_dirty';
5051
$country->name = 'abc';
5152
$this->assertFalse($country->save());
5253
}

0 commit comments

Comments
 (0)