Closed rabol closed 3 years ago
Hi, we use the forceful
method by default to be as open as possible to newbies who do not fill in the model properties.
But you can easily control these things: https://github.com/orchidsoftware/crud#resource-events
For example, you can put:
/**
* Action to create and update the model
*
* @param ResourceRequest $request
* @param Model $model
*/
public function onSave(ResourceRequest $request, Model $model)
{
$model->fill($request->all())->save();
}
But using forceFill() with e.g. a Matrix() will give you SQL errors
Why can you give an example? You put the matrix field to the model property that uses cast in JSON, for example
the saving of a resource uses forceFill() meaning that it will add fields to a model that is not in the db e.g. when using a matrix.