This commit is contained in:
denisdulici 2018-10-20 16:29:48 +03:00
parent 0abf3eae57
commit bbec3dafc2
2 changed files with 5 additions and 4 deletions

View File

@ -30,12 +30,13 @@ class Transactions extends Controller
$types = collect(['expense' => 'Expense', 'income' => 'Income'])
->prepend(trans('general.all_type', ['type' => trans_choice('general.types', 2)]), '');
$categories = collect(Category::enabled()->type('income')->pluck('name', 'id'))
->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), '');
$type = $request->get('type');
$type_cats = empty($type) ? ['income', 'expense'] : $type;
$categories = collect(Category::enabled()->type($type_cats)->pluck('name', 'id'))
->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), '');
if ($type != 'income') {
$this->addTransactions(Payment::collect(['paid_at'=> 'desc']), trans_choice('general.expenses', 1));
$this->addTransactions(BillPayment::collect(['paid_at'=> 'desc']), trans_choice('general.expenses', 1), trans_choice('general.bills', 1));

View File

@ -56,7 +56,7 @@ class Category extends Model
*/
public function scopeType($query, $type)
{
return $query->where('type', $type);
return $query->whereIn('type', (array) $type);
}
/**