mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
changed inserting method into the database
- this should be changed back later on once we finalised the fillable/guard fields on model classes.
This commit is contained in:
parent
35ffd32e27
commit
b35f37a0a9
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user