diff --git a/automationrules/conditions/ReviewCount.php b/automationrules/conditions/ReviewCount.php index d75ac44..5cb528a 100644 --- a/automationrules/conditions/ReviewCount.php +++ b/automationrules/conditions/ReviewCount.php @@ -31,13 +31,12 @@ public function defineModelAttributes() public function getReviewCountAttribute($value, $object) { - $object = array_get($params, 'order', array_get($params, 'reservation')); if (!$object instanceof Model) return false; - return Reviews_model::where([ - 'sale_id' => $object->order_id ?? $object->reservation_id, - 'sale_type' => $object->order_id ? 'orders' : 'reservations', + return Reviews_model::query()->where([ + 'sale_id' => $object->getKey(), + 'sale_type' => $object->getMorphClass(), ])->count(); } }