Welcome Guest, Not a member yet? Register   Sign In
Cancel $model->save($data) operation using $beforeInsert
#4

@littlej you cannot cancel an insert, partly because Events are potentially a chain spa ll need to return the data, transformed or not, for the next event. If I were you, I would extend the model and make my own insert() method something like this:
PHP Code:
public function insert($data nullbool $returnID true)
{

try
{
parent::insert($data$returnID);
}
catch (
CancelEventException $e)
{
return 
false;
}



And then you can define your own exception CancelEventException and throw it from uniqueTokenPerUser()

Sorry about the formatting, the forum software is freaking out on me.
Reply


Messages In This Thread
RE: Cancel $model->save($data) operation using $beforeInsert - by MGatner - 01-07-2020, 12:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB