Skip to content

Commit

Permalink
[8.x] Fix bug where columns would be guarded while filling Eloquent m…
Browse files Browse the repository at this point in the history
…odels during unit tests (#39880)

* Fix bug where columns would be guarded while filling Eloquent models during unit tests

* Update GuardsAttributes.php

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
robbieaverill and taylorotwell committed Dec 3, 2021
1 parent d4972ca commit 1225088
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -217,9 +217,14 @@ public function isGuarded($key)
protected function isGuardableColumn($key)
{
if (! isset(static::$guardableColumns[get_class($this)])) {
static::$guardableColumns[get_class($this)] = $this->getConnection()
$columns = $this->getConnection()
->getSchemaBuilder()
->getColumnListing($this->getTable());

if (empty($columns)) {
return true;
}
static::$guardableColumns[get_class($this)] = $columns;
}

return in_array($key, static::$guardableColumns[get_class($this)]);
Expand Down

0 comments on commit 1225088

Please sign in to comment.