Skip to content

Commit

Permalink
Added context filtering in generic controller
Browse files Browse the repository at this point in the history
  • Loading branch information
pecuchet committed May 26, 2023
1 parent 0454bec commit 0f5b3af
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Http/Controllers/MessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public function index(Request $request): LengthAwarePaginator
$query->whereIn('level', (array)Message::levelCode($levels));
}

if ($contexts = $request->get('contexts')) {
$contexts = array_filter(array_map('trim', explode(',', $contexts)));

$query->whereIn('context', $contexts);
}

$orderBy = $request->get('order_by') ?: 'created_at';

$direction = $request->get('order') ?: 'desc';
Expand Down

0 comments on commit 0f5b3af

Please sign in to comment.