Error: Call to a member function compileColumnListing() on null
/var/www/back/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:135
/var/www/back/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php:194
/var/www/back/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php:180
/var/www/back/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php:157
/var/www/back/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:329
/var/www/back/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:172
Steps to reproduce
Create a Moloquent model with guarded attributes.
use Jenssegers\Mongodb\Eloquent\Model as Moloquent;
2. Instanciate the model with mass assignement. Will cause the error above.
```php
$e = new Entity([
'name' => 'thingy',
'size' => 3,
'weight' => 45
]);
Using $fillable instead of $guarded works.
use Jenssegers\Mongodb\Eloquent\Model as Moloquent;
Description:
Since Laravel security update 6.18.35 (https://github.com/laravel/framework/releases/tag/v6.18.35), doing mass attribute assignment on a Moloquent object that has guarded attributes causes an error.
Steps to reproduce
class Entity extends Moloquent { protected $connection = 'mongodb'; protected $collection = 'entities'; protected $guarded = ['_id']; }
$fillable
instead of$guarded
works.class Entity extends Moloquent { protected $connection = 'mongodb'; protected $collection = 'entities'; protected $fillable = [ 'name', 'size', 'weight' ]; }
$e = new Entity([ 'name' => 'thingy', 'size' => 3, 'weight' => 45 ]);
protected function isGuardableColumn($key) { if (! isset(static::$guardableColumns[get_class($this)])) { static::$guardableColumns[get_class($this)] = $this->getConnection() ->getSchemaBuilder() ->getColumnListing($this->getTable()); }
}