Skip to content

Commit

Permalink
Fix review count automation condition attribute
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed Dec 3, 2022
1 parent 3137bf9 commit 25cc2c0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions automationrules/conditions/ReviewCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 25cc2c0

Please sign in to comment.