Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/UnderscoreTranslatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait UnderscoreTranslatable
{
protected ?string $translationLocale = null;

public function setLocale(string $locale): self
public function setLocale(?string $locale): self
{
$this->translationLocale = $locale;

Expand Down
13 changes: 13 additions & 0 deletions tests/UnderscoreTranslatableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ public function it_can_set_and_get_the_translation_locale(): void
$this->assertEquals('nl', $post->getLocale());
}

#[Test]
public function it_can_reset_the_translation_locale_by_passing_null(): void
{
config(['app.locale' => 'en']);

$post = new Post();
$post->setLocale('nl');
$this->assertEquals('nl', $post->getLocale());

$post->setLocale(null);
$this->assertEquals('en', $post->getLocale());
}

#[Test]
public function it_can_check_if_an_attribute_is_translatable(): void
{
Expand Down
Loading