Skip to content

Commit

Permalink
Add statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
OniiCoder committed Sep 23, 2023
1 parent eb84c4a commit 71ee95e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Http/Controllers/Api/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ public function index(Request $request): JsonResponse
$organization = $userOrganization->organization;

$all_time = (bool)$request->query('all_time');
$status = $request->query('status');
$statuses = $request->query('status') === 'DELIVERED' ? ['DELIVERED'] : ['PENDING', 'PROCESSING', 'DISPATCHED'];

if(!$all_time) {
$startDate = Carbon::createFromFormat('Y-m-d', $request->query('start_date'))->startOfDay();
$endDate = Carbon::createFromFormat('Y-m-d', $request->query('end_date'))->endOfDay();

$orders = Order::where('organization_id', $organization->id)
->where('status', $status)
->whereIn('status', $statuses)
->where('status', '<>', 'CANCELED')
->whereBetween('created_at', [$startDate, $endDate])
->orderBy('created_at', 'desc')
Expand Down

0 comments on commit 71ee95e

Please sign in to comment.