From 92eaf166933f0b2d3fd57a255b98b8d1be0582f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Sat, 26 Dec 2020 21:01:11 +0300 Subject: [PATCH] fixed scope for revenu/payment --- app/Traits/Scopes.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/Traits/Scopes.php b/app/Traits/Scopes.php index c688f69d3..136a11a74 100644 --- a/app/Traits/Scopes.php +++ b/app/Traits/Scopes.php @@ -22,7 +22,7 @@ trait Scopes return; } - $type = request()->get('type') ?: Str::singular(request()->segment(2, '')); + $type = request()->get('type') ?: $this->getTypeFromUrl(); // Apply type scope $builder->where($model->getTable() . '.type', '=', $type); @@ -59,4 +59,19 @@ trait Scopes return false; } + + public function getTypeFromUrl() + { + $type = Str::singular(request()->segment(2, '')); + + if ($type == 'revenue') { + $type = 'income'; + } + + if ($type == 'payment') { + $type = 'expense'; + } + + return $type; + } }