diff --git a/app/Repositories/DatabaseRepository.php b/app/Repositories/DatabaseRepository.php index 84aa2f4..200b59e 100644 --- a/app/Repositories/DatabaseRepository.php +++ b/app/Repositories/DatabaseRepository.php @@ -57,7 +57,19 @@ class DatabaseRepository extends RepositoryQuery implements Repository // this way we trigger scout to index records in the search index. $modelClass = $this->getModelClass(); /** @noinspection PhpUndefinedMethodInspection */ - $modelClass::create($attributes); + $modelInstance = new $modelClass(); + // fixme: change this to $modelClass::create() call, because that one protects against + // mass assignment. This way of doing it is just a work around to make sure all attributes + // land in the database. The "fillable" and "guard" fields of models should be populated + // correctly. + $modelInstance->fill($attributes); + foreach(["request_hash", "modifiedAt", "createdAt"] as $metaField) { + if (array_key_exists($metaField, $attributes)) { + $modelInstance->$metaField = $attributes[$metaField]; + } + } + + $modelInstance->save(); return true; }