From a52d3aa9035dfb0793b384d91dea0eabed0b50d3 Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 23 Jul 2020 23:00:19 +0300 Subject: [PATCH] feat(element-queries): updates for collect_filter #436 --- src/flextype/Support/helpers.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/flextype/Support/helpers.php b/src/flextype/Support/helpers.php index 7a2cb307..c26e11ea 100644 --- a/src/flextype/Support/helpers.php +++ b/src/flextype/Support/helpers.php @@ -38,16 +38,16 @@ if (! function_exists('collect_filter')) { $direction = $collection->direction; // Bind: set first result - $bind_set_first_result = $filter['set_first_result'] ?? false; + $bind_set_first_result_value = $filter['set_first_result'] ?? 0; // Bind: set max result - $bind_set_max_result = $filter['limit'] ?? false; + $bind_set_max_result_value = $filter['limit'] ?? 0; // Bind: return $bind_return = $filter['return'] ?? 'all'; - // Bind: random_value - $bind_random_value = $filter['random_value'] ?? 1; + // Bind: random + $bind_random_value = $filter['random'] ?? 1; // Bind: where $bind_where = []; @@ -138,6 +138,12 @@ if (! function_exists('collect_filter')) { case 'random': $items = $collection->random($bind_random_value); break; + case 'limit': + $items = $collection->limit($bind_set_max_result_value); + break; + case 'set_first_result': + $items = $collection->setFirstResult($bind_set_first_result_value); + break; case 'shuffle': $items = $collection->shuffle(); break;