From 2de0a3669e8d30b92d6504ab604d5bc320554ca2 Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 4 Nov 2017 01:11:11 -0700 Subject: [PATCH] Check that there is a valid array before unshifting --- app/Http/Transformers/SelectlistTransformer.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Transformers/SelectlistTransformer.php b/app/Http/Transformers/SelectlistTransformer.php index 6aac737b07..e4b6a17a0f 100644 --- a/app/Http/Transformers/SelectlistTransformer.php +++ b/app/Http/Transformers/SelectlistTransformer.php @@ -34,7 +34,10 @@ class SelectlistTransformer // This is weird and awful, but the only way I can find to allow the user to // clear the selection - @snipe - array_unshift($items_array, ['id' =>'', 'text'=> trans('general.clear_selection')]); + if (count($items_array) > 0) { + array_unshift($items_array, ['id' =>'', 'text'=> trans('general.clear_selection')]); + } + $results = [ 'items' => $items_array, 'pagination' =>