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; + } }