added more scopes

This commit is contained in:
denisdulici
2020-05-03 11:15:56 +03:00
parent 70bfe8c524
commit 430c092ebe
32 changed files with 115 additions and 49 deletions

View File

@ -15,7 +15,7 @@ class ExpensesByCategory extends Widget
public function show()
{
Category::with('expense_transactions')->type('expense')->each(function ($category) {
Category::with('expense_transactions')->expense()->each(function ($category) {
$amount = 0;
$this->applyFilters($category->expense_transactions())->each(function ($transaction) use (&$amount) {

View File

@ -15,7 +15,7 @@ class IncomeByCategory extends Widget
public function show()
{
Category::with('income_transactions')->type('income')->each(function ($category) {
Category::with('income_transactions')->income()->each(function ($category) {
$amount = 0;
$this->applyFilters($category->income_transactions())->each(function ($transaction) use (&$amount) {

View File

@ -11,7 +11,7 @@ class LatestExpenses extends Widget
public function show()
{
$transactions = $this->applyFilters(Transaction::with('category')->type('expense')->orderBy('paid_at', 'desc')->isNotTransfer()->take(5))->get();
$transactions = $this->applyFilters(Transaction::with('category')->expense()->orderBy('paid_at', 'desc')->isNotTransfer()->take(5))->get();
return $this->view('widgets.latest_expenses', [
'transactions' => $transactions,

View File

@ -11,7 +11,7 @@ class LatestIncome extends Widget
public function show()
{
$transactions = $this->applyFilters(Transaction::with('category')->type('income')->orderBy('paid_at', 'desc')->isNotTransfer()->take(5))->get();
$transactions = $this->applyFilters(Transaction::with('category')->income()->orderBy('paid_at', 'desc')->isNotTransfer()->take(5))->get();
return $this->view('widgets.latest_income', [
'transactions' => $transactions,

View File

@ -18,7 +18,7 @@ class TotalExpenses extends Widget
{
$current = $open = $overdue = 0;
$this->applyFilters(Transaction::type('expense')->isNotTransfer())->each(function ($transaction) use (&$current) {
$this->applyFilters(Transaction::expense()->isNotTransfer())->each(function ($transaction) use (&$current) {
$current += $transaction->getAmountConvertedToDefault();
});

View File

@ -18,7 +18,7 @@ class TotalIncome extends Widget
{
$current = $open = $overdue = 0;
$this->applyFilters(Transaction::type('income')->isNotTransfer())->each(function ($transaction) use (&$current) {
$this->applyFilters(Transaction::income()->isNotTransfer())->each(function ($transaction) use (&$current) {
$current += $transaction->getAmountConvertedToDefault();
});