Skip to content

Commit

Permalink
fix casing issue with guarded
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Aug 5, 2020
1 parent 27283b6 commit 1b70bef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function isFillable($key)
*/
public function isGuarded($key)
{
return in_array($key, $this->getGuarded()) || $this->getGuarded() == ['*'];
return $this->getGuarded() == ['*'] || ! empty(preg_grep('/^'.preg_quote($key).'$/i', $this->getGuarded()));
}

/**
Expand Down
9 changes: 9 additions & 0 deletions tests/Integration/Database/EloquentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ protected function setUp(): void
});
}

public function testCantUpdateGuardedAttributesUsingDifferentCasing()
{
$model = new TestModel2;

$model->fill(['ID' => 123]);

$this->assertNull($model->ID);
}

public function testUserCanUpdateNullableDate()
{
$user = TestModel1::create([
Expand Down

0 comments on commit 1b70bef

Please sign in to comment.