mardi 5 octobre 2021

Check Status Of All Orders In a Deal And Mark Deal as Completed

work_orders is hasMany() relationship.

foreach ($deal->work_orders as  $work_order) {
            if ($work_order->status != completed) {
                return 0;
            } else {
                completeDeal($deal->id);
            }
        }

I want to check If All Of the Orders in a deal are completed then run a function to complete a deal. If any of work orders is not completed Then Just Do nothing and return back. Issue with my current code is that If any of the work order is completed it marks deal complete. But I want to check if all order are completed

Aucun commentaire:

Enregistrer un commentaire