fixed scope for revenu/payment

This commit is contained in:
Denis Duliçi 2020-12-26 21:01:11 +03:00
parent 76b1196200
commit 92eaf16693

View File

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