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

Commit

Permalink
Fixed: translations not saved when object not dirty. (laravel core wa…
Browse files Browse the repository at this point in the history
…s updated)
  • Loading branch information
dimsav committed Jun 20, 2014
1 parent 6f4f544 commit ace069b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions Translatable/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,18 @@ public function setAttribute($key, $value)

public function save(array $options = array())
{
if (parent::save($options))
if (count($this->getDirty()) > 0)
{
if (parent::save($options))
{
return $this->saveTranslations();
}
return false;
}
else
{
return $this->saveTranslations();
}
return false;
}

public function fill(array $attributes)
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCoreModelExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function it_throws_query_exception_if_saving_and_name_is_null()
/**
* @test
*/
public function it_returns_false_if_save_was_not_successful()
public function it_returns_false_if_parent_save_was_not_successful()
{
$that = $this;
$event = App::make('events');
Expand All @@ -47,6 +47,7 @@ public function it_returns_false_if_save_was_not_successful()
});

$country = Country::find(1);
$country->iso = 'make_model_dirty';
$country->name = 'abc';
$this->assertFalse($country->save());
}
Expand Down

0 comments on commit ace069b

Please sign in to comment.