cloudcake / laravel-approval

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

Updating model status_id if it has a pending modification #7

Closed Mohmdthabet closed 5 years ago

Mohmdthabet commented 5 years ago

how can i update the status id column of the model when it has pending modifications. something like this:

protected function requiresApprovalWhen(array $modifications) : bool{ $fields_approval = [ 'id', 'partner_id', 'service_id', 'policy_no', 'policy_code', 'effective_date', 'expiry_date', 'issuing_date', 'renewal_duration', 'sum_insured', 'gross_premium', 'net_premium', 'is_renewable', 'is_flat_commissioned', 'flat_commission_rate', 'status_id','currency_id', ]; foreach($modifications as $key =>$modification){ if(in_array($key,$fields_approval)){ // Update the model status_id column logic here return true; } } // Handle some logic that determines if this change requires approval // // Return true if the model requires approval, return false if it // should update immediately without approval. return false; } the modifications array doesn't contain the model id

stephenlake commented 5 years ago

The function lives on the model. $this->attributes['id'].