diff --git a/app/Filters/Banking/Reconciliations.php b/app/Filters/Banking/Reconciliations.php index f7a839c26..3628cd609 100644 --- a/app/Filters/Banking/Reconciliations.php +++ b/app/Filters/Banking/Reconciliations.php @@ -14,8 +14,8 @@ class Reconciliations extends ModelFilter */ public $relations = []; - public function account($account) + public function accounts($accounts) { - return $this->where('account_id', $account); + return $this->whereIn('account_id', (array) $accounts); } } \ No newline at end of file diff --git a/app/Filters/Banking/Transactions.php b/app/Filters/Banking/Transactions.php index 89a0f33d0..b9dc8ad34 100644 --- a/app/Filters/Banking/Transactions.php +++ b/app/Filters/Banking/Transactions.php @@ -14,19 +14,19 @@ class Transactions extends ModelFilter */ public $relations = []; - public function account($account_id) + public function accounts($accounts) { - return $this->where('account_id', $account_id); + return $this->whereIn('account_id', (array) $accounts); } - public function category($category_id) + public function categories($categories) { // No category for bills/invoices if (in_array($this->getModel()->getTable(), ['bill_payments', 'invoice_payments'])) { return $this; } - return $this->where('category_id', $category_id); + return $this->whereIn('category_id', (array) $categories); } public function date($date) diff --git a/app/Filters/Common/Items.php b/app/Filters/Common/Items.php index ec3a21825..9c6369953 100644 --- a/app/Filters/Common/Items.php +++ b/app/Filters/Common/Items.php @@ -19,8 +19,8 @@ class Items extends ModelFilter return $this->whereLike('name', $query); } - public function category($id) + public function categories($ids) { - return $this->where('category_id', $id); + return $this->whereIn('category_id', (array) $ids); } } diff --git a/app/Filters/Expenses/Bills.php b/app/Filters/Expenses/Bills.php index d626f1a33..06ae99b3d 100644 --- a/app/Filters/Expenses/Bills.php +++ b/app/Filters/Expenses/Bills.php @@ -19,14 +19,19 @@ class Bills extends ModelFilter return $this->whereLike('vendor_name', $query); } - public function vendor($vendor) + public function vendors($vendors) { - return $this->where('vendor_id', $vendor); + return $this->whereIn('vendor_id', (array) $vendors); } - public function status($status) + public function categories($categories) { - return $this->where('bill_status_code', $status); + return $this->whereIn('category_id', (array) $categories); + } + + public function statuses($statuses) + { + return $this->whereIn('bill_status_code', (array) $statuses); } public function billDate($date) diff --git a/app/Filters/Expenses/Payments.php b/app/Filters/Expenses/Payments.php index 54a786c37..834f5f71a 100644 --- a/app/Filters/Expenses/Payments.php +++ b/app/Filters/Expenses/Payments.php @@ -19,19 +19,19 @@ class Payments extends ModelFilter return $this->whereLike('description', $query); } - public function vendor($vendor) + public function vendors($vendors) { - return $this->where('vendor_id', $vendor); + return $this->whereIn('vendor_id', (array) $vendors); } - public function category($category) + public function categories($categories) { - return $this->where('category_id', $category); + return $this->whereIn('category_id', (array) $categories); } - public function account($account) + public function accounts($accounts) { - return $this->where('account_id', $account); + return $this->whereIn('account_id', (array) $accounts); } public function date($date) diff --git a/app/Filters/Incomes/Invoices.php b/app/Filters/Incomes/Invoices.php index 7e1acabc4..f473d1455 100644 --- a/app/Filters/Incomes/Invoices.php +++ b/app/Filters/Incomes/Invoices.php @@ -19,14 +19,19 @@ class Invoices extends ModelFilter return $this->whereLike('customer_name', $query); } - public function customer($customer) + public function customers($customers) { - return $this->where('customer_id', $customer); + return $this->whereIn('customer_id', (array) $customers); } - public function status($status) + public function categories($categories) { - return $this->where('invoice_status_code', $status); + return $this->whereIn('category_id', (array) $categories); + } + + public function statuses($statuses) + { + return $this->whereIn('invoice_status_code', (array) $statuses); } public function invoiceDate($date) diff --git a/app/Filters/Incomes/Revenues.php b/app/Filters/Incomes/Revenues.php index 93aede017..9d200accc 100644 --- a/app/Filters/Incomes/Revenues.php +++ b/app/Filters/Incomes/Revenues.php @@ -19,19 +19,19 @@ class Revenues extends ModelFilter return $this->whereLike('description', $query); } - public function customer($customer) + public function customers($customers) { - return $this->where('customer_id', $customer); + return $this->whereIn('customer_id', (array) $customers); } - public function category($category) + public function categories($categories) { - return $this->where('category_id', $category); + return $this->whereIn('category_id', (array) $categories); } - public function account($account) + public function accounts($accounts) { - return $this->where('account_id', $account); + return $this->whereIn('account_id', (array) $accounts); } public function date($date) diff --git a/app/Filters/Settings/Categories.php b/app/Filters/Settings/Categories.php index ebb50b667..9b8445823 100644 --- a/app/Filters/Settings/Categories.php +++ b/app/Filters/Settings/Categories.php @@ -19,8 +19,8 @@ class Categories extends ModelFilter return $this->whereLike('name', $query); } - public function type($type) + public function types($types) { - return $this->where('type', $type); + return $this->whereIn('type', (array) $types); } } diff --git a/app/Http/Controllers/Banking/Reconciliations.php b/app/Http/Controllers/Banking/Reconciliations.php index 035d97f07..c1192fa3b 100644 --- a/app/Http/Controllers/Banking/Reconciliations.php +++ b/app/Http/Controllers/Banking/Reconciliations.php @@ -20,8 +20,7 @@ class Reconciliations extends Controller { $reconciliations = Reconciliation::collect(); - $accounts = collect(Account::enabled()->orderBy('name')->pluck('name', 'id')) - ->prepend(trans('general.all_type', ['type' => trans_choice('general.accounts', 2)]), ''); + $accounts = collect(Account::enabled()->orderBy('name')->pluck('name', 'id')); return view('banking.reconciliations.index', compact('reconciliations', 'accounts')); } diff --git a/app/Http/Controllers/Banking/Transactions.php b/app/Http/Controllers/Banking/Transactions.php index dc6645709..a5133c42b 100644 --- a/app/Http/Controllers/Banking/Transactions.php +++ b/app/Http/Controllers/Banking/Transactions.php @@ -25,8 +25,7 @@ class Transactions extends Controller { $request = request(); - $accounts = collect(Account::enabled()->pluck('name', 'id')) - ->prepend(trans('general.all_type', ['type' => trans_choice('general.accounts', 2)]), ''); + $accounts = collect(Account::enabled()->pluck('name', 'id')); $types = collect(['expense' => 'Expense', 'income' => 'Income']) ->prepend(trans('general.all_type', ['type' => trans_choice('general.types', 2)]), ''); @@ -34,8 +33,7 @@ class Transactions extends Controller $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)]), ''); + $categories = collect(Category::enabled()->type($type_cats)->pluck('name', 'id')); if ($type != 'income') { $this->addTransactions(Payment::collect(['paid_at'=> 'desc']), trans_choice('general.expenses', 1)); diff --git a/app/Http/Controllers/Common/Items.php b/app/Http/Controllers/Common/Items.php index cad690c4d..67966cbc4 100644 --- a/app/Http/Controllers/Common/Items.php +++ b/app/Http/Controllers/Common/Items.php @@ -26,8 +26,7 @@ class Items extends Controller { $items = Item::with('category')->collect(); - $categories = Category::enabled()->orderBy('name')->type('item')->pluck('name', 'id') - ->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), ''); + $categories = Category::enabled()->orderBy('name')->type('item')->pluck('name', 'id'); return view('common.items.index', compact('items', 'categories')); } diff --git a/app/Http/Controllers/Expenses/Bills.php b/app/Http/Controllers/Expenses/Bills.php index 778a9ec8d..5dd6c2b7e 100644 --- a/app/Http/Controllers/Expenses/Bills.php +++ b/app/Http/Controllers/Expenses/Bills.php @@ -47,13 +47,13 @@ class Bills extends Controller { $bills = Bill::with(['vendor', 'status', 'items', 'payments', 'histories'])->collect(['billed_at'=> 'desc']); - $vendors = collect(Vendor::enabled()->orderBy('name')->pluck('name', 'id')) - ->prepend(trans('general.all_type', ['type' => trans_choice('general.vendors', 2)]), ''); + $vendors = collect(Vendor::enabled()->orderBy('name')->pluck('name', 'id')); - $statuses = collect(BillStatus::all()->pluck('name', 'code')) - ->prepend(trans('general.all_type', ['type' => trans_choice('general.statuses', 2)]), ''); + $categories = collect(Category::enabled()->type('expense')->orderBy('name')->pluck('name', 'id')); - return view('expenses.bills.index', compact('bills', 'vendors', 'statuses')); + $statuses = collect(BillStatus::all()->pluck('name', 'code')); + + return view('expenses.bills.index', compact('bills', 'vendors', 'categories', 'statuses')); } /** diff --git a/app/Http/Controllers/Expenses/Payments.php b/app/Http/Controllers/Expenses/Payments.php index 6a7fb1ecf..dc76daee9 100644 --- a/app/Http/Controllers/Expenses/Payments.php +++ b/app/Http/Controllers/Expenses/Payments.php @@ -27,14 +27,11 @@ class Payments extends Controller { $payments = Payment::with(['vendor', 'account', 'category'])->isNotTransfer()->collect(['paid_at'=> 'desc']); - $vendors = collect(Vendor::enabled()->orderBy('name')->pluck('name', 'id')) - ->prepend(trans('general.all_type', ['type' => trans_choice('general.vendors', 2)]), ''); + $vendors = collect(Vendor::enabled()->orderBy('name')->pluck('name', 'id')); - $categories = collect(Category::enabled()->type('expense')->orderBy('name')->pluck('name', 'id')) - ->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), ''); + $categories = collect(Category::enabled()->type('expense')->orderBy('name')->pluck('name', 'id')); - $accounts = collect(Account::enabled()->orderBy('name')->pluck('name', 'id')) - ->prepend(trans('general.all_type', ['type' => trans_choice('general.accounts', 2)]), ''); + $accounts = collect(Account::enabled()->orderBy('name')->pluck('name', 'id')); $transfer_cat_id = Category::transfer(); diff --git a/app/Http/Controllers/Incomes/Invoices.php b/app/Http/Controllers/Incomes/Invoices.php index 027928e16..c1e18ea54 100644 --- a/app/Http/Controllers/Incomes/Invoices.php +++ b/app/Http/Controllers/Incomes/Invoices.php @@ -52,13 +52,13 @@ class Invoices extends Controller { $invoices = Invoice::with(['customer', 'status', 'items', 'payments', 'histories'])->collect(['invoice_number'=> 'desc']); - $customers = collect(Customer::enabled()->orderBy('name')->pluck('name', 'id')) - ->prepend(trans('general.all_type', ['type' => trans_choice('general.customers', 2)]), ''); + $customers = collect(Customer::enabled()->orderBy('name')->pluck('name', 'id')); - $status = collect(InvoiceStatus::all()->pluck('name', 'code')) - ->prepend(trans('general.all_type', ['type' => trans_choice('general.statuses', 2)]), ''); + $categories = collect(Category::enabled()->type('income')->orderBy('name')->pluck('name', 'id')); - return view('incomes.invoices.index', compact('invoices', 'customers', 'status')); + $statuses = collect(InvoiceStatus::all()->pluck('name', 'code')); + + return view('incomes.invoices.index', compact('invoices', 'customers', 'categories', 'statuses')); } /** diff --git a/app/Http/Controllers/Incomes/Revenues.php b/app/Http/Controllers/Incomes/Revenues.php index a8a87d56f..1ef8d4d5e 100644 --- a/app/Http/Controllers/Incomes/Revenues.php +++ b/app/Http/Controllers/Incomes/Revenues.php @@ -29,14 +29,11 @@ class Revenues extends Controller { $revenues = Revenue::with(['account', 'category', 'customer'])->isNotTransfer()->collect(['paid_at'=> 'desc']); - $customers = collect(Customer::enabled()->orderBy('name')->pluck('name', 'id')) - ->prepend(trans('general.all_type', ['type' => trans_choice('general.customers', 2)]), ''); + $customers = collect(Customer::enabled()->orderBy('name')->pluck('name', 'id')); - $categories = collect(Category::enabled()->type('income')->orderBy('name')->pluck('name', 'id')) - ->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), ''); + $categories = collect(Category::enabled()->type('income')->orderBy('name')->pluck('name', 'id')); - $accounts = collect(Account::enabled()->orderBy('name')->pluck('name', 'id')) - ->prepend(trans('general.all_type', ['type' => trans_choice('general.accounts', 2)]), ''); + $accounts = collect(Account::enabled()->orderBy('name')->pluck('name', 'id')); $transfer_cat_id = Category::transfer(); diff --git a/app/Http/Controllers/Settings/Categories.php b/app/Http/Controllers/Settings/Categories.php index 5b856b953..d84baecb9 100644 --- a/app/Http/Controllers/Settings/Categories.php +++ b/app/Http/Controllers/Settings/Categories.php @@ -25,7 +25,7 @@ class Categories extends Controller 'income' => trans_choice('general.incomes', 1), 'item' => trans_choice('general.items', 1), 'other' => trans_choice('general.others', 1), - ])->prepend(trans('general.all_type', ['type' => trans_choice('general.types', 2)]), ''); + ]); return view('settings.categories.index', compact('categories', 'types', 'transfer_id')); } diff --git a/resources/views/banking/reconciliations/index.blade.php b/resources/views/banking/reconciliations/index.blade.php index 78de5b513..1d8f40dfb 100644 --- a/resources/views/banking/reconciliations/index.blade.php +++ b/resources/views/banking/reconciliations/index.blade.php @@ -13,9 +13,9 @@