Skip to content

Commit

Permalink
fix: realtime bug
Browse files Browse the repository at this point in the history
  • Loading branch information
phojie committed Jan 12, 2023
1 parent d3b778c commit 34c3bcf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
16 changes: 8 additions & 8 deletions app/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ public function scopeSearch($query, $search): object
return $query->when(
$search,
fn ($q) => $q->where('order_number', 'ilike', "%{$search}%")
->orWhere('name', 'ilike', "%{$search}%")
->orWhere('email', 'ilike', "%{$search}%")
->orWhere('phone', 'ilike', "%{$search}%")
->orWhere('address', 'ilike', "%{$search}%")
->orWhere('city', 'ilike', "%{$search}%")
->orWhere('province', 'ilike', "%{$search}%")
->orWhere('postal_code', 'ilike', "%{$search}%")
->orWhere('status', 'ilike', "%{$search}%")
->orWhere('name', 'ilike', "%{$search}%")
->orWhere('email', 'ilike', "%{$search}%")
->orWhere('phone', 'ilike', "%{$search}%")
->orWhere('address', 'ilike', "%{$search}%")
->orWhere('city', 'ilike', "%{$search}%")
->orWhere('province', 'ilike', "%{$search}%")
->orWhere('postal_code', 'ilike', "%{$search}%")
->orWhere('status', 'ilike', "%{$search}%")
);
}

Expand Down
9 changes: 2 additions & 7 deletions app/Services/OrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ public function update(OrderRequest $request, Order $order): void
});
}

// if status is changed
if ($order->getOriginal('status') !== $request->status) {
// broadcast order status updated
broadcast(new OrderStatusUpdated($order));
}

$order->update([
'name' => $request->name,
'email' => $request->email,
Expand All @@ -93,7 +87,8 @@ public function update(OrderRequest $request, Order $order): void
});
}

broadcast(new PendingOrdersNumber());
broadcast(new OrderStatusUpdated($order));
broadcast(new PendingOrdersNumber());
});
} catch (\Exception $e) {
throw $e;
Expand Down

0 comments on commit 34c3bcf

Please sign in to comment.