new widget structure

This commit is contained in:
denisdulici
2019-12-31 02:20:10 +03:00
parent 8c6ca5e5fb
commit 71c5caf264
44 changed files with 333 additions and 502 deletions

View File

@@ -11,9 +11,13 @@ class AccountBalance extends Widget
{
$accounts = Account::enabled()->take(5)->get();
return view('widgets.account_balance', [
'config' => (object) $this->config,
return $this->view('widgets.account_balance', [
'accounts' => $accounts,
]);
}
public function getDefaultName()
{
return trans('widgets.account_balance');
}
}

View File

@@ -13,10 +13,6 @@ class CashFlow extends Widget
{
use Currencies, DateTime;
protected $config = [
'width' => 'col-md-12',
];
public function show()
{
$financial_start = $this->getFinancialStart()->format('Y-m-d');
@@ -96,8 +92,7 @@ class CashFlow extends Widget
])
->fill(false);
return view('widgets.cash_flow', [
'config' => (object) $this->config,
return $this->view('widgets.cash_flow', [
'chart' => $chart,
]);
}
@@ -175,4 +170,16 @@ class CashFlow extends Widget
return $profit;
}
public function getDefaultName()
{
return trans('widgets.cash_flow');
}
public function getDefaultSettings()
{
return [
'width' => 'col-md-12',
];
}
}

View File

@@ -7,10 +7,6 @@ use App\Models\Setting\Category;
class ExpensesByCategory extends Widget
{
protected $config = [
'width' => 'col-md-6',
];
public function show()
{
Category::with('expense_transactions')->type('expense')->enabled()->each(function ($category) {
@@ -27,9 +23,20 @@ class ExpensesByCategory extends Widget
$chart = $this->getDonutChart(trans_choice('general.expenses', 2), 0, 160, 6);
return view('widgets.expenses_by_category', [
'config' => (object) $this->config,
return $this->view('widgets.expenses_by_category', [
'chart' => $chart,
]);
}
public function getDefaultName()
{
return trans('widgets.expenses_by_category');
}
public function getDefaultSettings()
{
return [
'width' => 'col-md-6',
];
}
}

View File

@@ -7,10 +7,6 @@ use App\Models\Setting\Category;
class IncomeByCategory extends Widget
{
protected $config = [
'width' => 'col-md-6',
];
public function show()
{
Category::with('income_transacions')->type('income')->enabled()->each(function ($category) {
@@ -27,9 +23,20 @@ class IncomeByCategory extends Widget
$chart = $this->getDonutChart(trans_choice('general.incomes', 1), 0, 160, 6);
return view('widgets.income_by_category', [
'config' => (object) $this->config,
return $this->view('widgets.income_by_category', [
'chart' => $chart,
]);
}
public function getDefaultName()
{
return trans('widgets.income_by_category');
}
public function getDefaultSettings()
{
return [
'width' => 'col-md-6',
];
}
}

View File

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

View File

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

View File

@@ -36,9 +36,13 @@ class TotalExpenses extends Widget
'progress' => $progress,
];
return view('widgets.total_expenses', [
'config' => (object) $this->config,
return $this->view('widgets.total_expenses', [
'totals' => $totals,
]);
}
public function getDefaultName()
{
return trans('widgets.total_expenses');
}
}

View File

@@ -30,15 +30,19 @@ class TotalIncome extends Widget
}
$totals = [
'current' => $current,
'open' => money($open, setting('default.currency'), true),
'overdue' => money($overdue, setting('default.currency'), true),
'progress' => $progress,
'current' => $current,
'open' => money($open, setting('default.currency'), true),
'overdue' => money($overdue, setting('default.currency'), true),
'progress' => $progress,
];
return view('widgets.total_income', [
'config' => (object) $this->config,
return $this->view('widgets.total_income', [
'totals' => $totals,
]);
}
public function getDefaultName()
{
return trans('widgets.total_income');
}
}

View File

@@ -55,9 +55,13 @@ class TotalProfit extends Widget
'progress' => $progress,
];
return view('widgets.total_profit', [
'config' => (object) $this->config,
return $this->view('widgets.total_profit', [
'totals' => $totals,
]);
}
public function getDefaultName()
{
return trans('widgets.total_profit');
}
}