找到你要的答案

Q:Check if validation of model has been failed

Q:检查模型的验证是否失败

I need to delete another model if current model has been failed on save.

trying:

$saved = $model->save(); // if validation fails the application has aborted

// never executes this    
if ( !$saved ) {
  $anotherModel->delete();
}

how do that?

如果当前模型保存失败,我需要删除另一个模型。

尝试:

$saved = $model->save(); // if validation fails the application has aborted

// never executes this    
if ( !$saved ) {
  $anotherModel->delete();
}

怎么办?

laravel