cloudcake / laravel-approval

Attach an approval process to any model, approve and disapprove from any other model, for Laravel.
MIT License
140 stars 15 forks source link

Skip approval when creating the model [question] #23

Closed mlab817 closed 3 years ago

mlab817 commented 3 years ago

I've tried to google this but can't find the answer anywhere. Basically, I want to skip approval process when the user is just creating a model. The package provides a function:

public function requiresApprovalWhen($modifications): bool
{
    // logic for requiring approval or not
    // ideally, i will return false here if the model is just being created
}

Upon checking the $modifications variable however, it only contains the incoming values. Thus, I can't check if the action is to create a new model or not.

How do I go about this?

emregocer commented 3 years ago

I think you could instantiate your model class and fill it with your data then use the setForcedApprovalUpdate method on it before saving.

mlab817 commented 3 years ago

Ok, thanks. will try that.