skip scope if type is empty
This commit is contained in:
parent
1abb446f93
commit
f8d0075f79
@ -27,8 +27,14 @@ trait Scopes
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$type = $this->getTypeFromRequest();
|
||||||
|
|
||||||
|
if (empty($type)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Apply type scope
|
// Apply type scope
|
||||||
$builder->where($model->getTable() . '.type', '=', $this->getTypeFromRequest());
|
$builder->where($model->getTable() . '.type', '=', $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +71,7 @@ trait Scopes
|
|||||||
|
|
||||||
public function getTypeFromRequest()
|
public function getTypeFromRequest()
|
||||||
{
|
{
|
||||||
$type = request()->get('type') ?: Str::singular(request()->segment(2, ''));
|
$type = request()->get('type') ?: Str::singular((string) request()->segment(2));
|
||||||
|
|
||||||
if ($type == 'revenue') {
|
if ($type == 'revenue') {
|
||||||
$type = 'income';
|
$type = 'income';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user