Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUGFIX: If an array $attributes exists in the model, its data is writ…
…ten to the table when the repository is updated (#751) Details in test: https://github.com/akmktz/l5repository_test_bug See readme
- Loading branch information
ad55bf2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that this problem exists on the create() method as well.
Since the model is filled with the attributes on the create and then the toArray() is called, any appends attributes will be returned.
Attempting to save the model will generate an error from the database because the appends attributes don't have columns in the model table
public function create(array $attributes)
{
if (!is_null($this->validator)) {
// we should pass data that has been casts by the model
// to make sure data type are same because validator may need to use
// this data to compare with data that fetch from database.
if ($this->versionCompare($this->app->version(), "5.2.*", ">")) {
$attributes = $this->model->newInstance()->forceFill($attributes)->makeVisible($this->model->getHidden())->toArray();