From c9e3fc4ddaad9c97baf7383281f0580d1a3e52e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Wed, 2 Nov 2022 17:01:32 +0300 Subject: [PATCH] Tip always show one item --- app/View/Components/Tips.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/View/Components/Tips.php b/app/View/Components/Tips.php index 58936daac..2d6504f8e 100644 --- a/app/View/Components/Tips.php +++ b/app/View/Components/Tips.php @@ -52,6 +52,10 @@ class Tips extends Component $view = 'components.tips.relative'; } + if ($this->tips->count() > 1) { + $view = 'components.tips.relative'; + } + return view($view); } @@ -71,6 +75,10 @@ class Tips extends Component return; } + $rows = collect(); + + shuffle($tips); + foreach ($tips as $tip) { if ($tip->position != $this->position) { continue; @@ -84,7 +92,13 @@ class Tips extends Component $tip->action = Str::replace('{company_id}', company_id(), $tip->action); } - $this->tips->push($tip); + $rows->push($tip); + } + + if ($rows->count()) { + $row = $rows->shuffle()->first(); + + $this->tips->push($row); } } }