restrict query in callback |
Hi,
I want to do some checks prior to some queries in the model. In the $beforeUpdate and $beforeDelete callback I append the query by PHP Code: $this->builder()->where('id', null); But this won't work on an insert. I have a callback which determines whether the insert is valid, but I can't find a way to prevent the insert from happening when the right conditions are not met. I have tried $this->builder()->resetQuery, but that still doesn't prevent the query from running...
I've looked into that....
But how would I fit that into a callback function in the Model? I don't want to use the WHEN method on every insert query, I would like to centralize it in the model
Why don't you throw an exception when the conditions are not met?
|
Welcome Guest, Not a member yet? Register Sign In |