Skip to content

Commit

Permalink
Log OrderStatus Change
Browse files Browse the repository at this point in the history
  • Loading branch information
bdsumon4u committed Sep 15, 2024
1 parent bbdfc7b commit ead50f0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions app/Http/Controllers/Admin/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,9 @@ public function status(Request $request)

$data['status'] = $request->status;
$data['status_at'] = now()->toDateTimeString();
$query = Order::whereIn('id', $request->order_id)->where('status', '!=', $request->status);
$orders = Order::whereIn('id', $request->order_id)->where('status', '!=', $request->status)->get();

if ($request->status == 'CONFIRMED') {
$orders = $query->get();
}

$query->update($data);
$orders->each->update($data);

if ($request->status == 'CONFIRMED') {
$orders->each(fn ($order) => $order->user->notify(new OrderConfirmed($order)));
Expand Down

0 comments on commit ead50f0

Please sign in to comment.