diff --git a/app/Abstracts/Widget.php b/app/Abstracts/Widget.php index abe69783b..ac7a4e766 100644 --- a/app/Abstracts/Widget.php +++ b/app/Abstracts/Widget.php @@ -2,7 +2,6 @@ namespace App\Abstracts; -use App\Models\Sale\Invoice; use App\Traits\Charts; use Date; @@ -12,21 +11,39 @@ abstract class Widget public $model; + public $default_name = ''; + + public $default_settings = [ + 'width' => 'col-md-4', + ]; + + public $views = [ + 'header' => 'partials.widgets.standard_header', + ]; + public function __construct($model = null) { $this->model = $model; } + public function getDefaultName() + { + return trans($this->default_name); + } + public function getDefaultSettings() { - return [ - 'width' => 'col-md-4', - ]; + return $this->default_settings; + } + + public function getViews() + { + return $this->views; } public function view($name, $data = []) { - return view($name, array_merge(['model' => $this->model], (array) $data)); + return view($name, array_merge(['class' => $this], (array) $data)); } public function applyFilters($model, $args = ['date_field' => 'paid_at']) diff --git a/app/Widgets/AccountBalance.php b/app/Widgets/AccountBalance.php index 41a6978bb..5318d18aa 100644 --- a/app/Widgets/AccountBalance.php +++ b/app/Widgets/AccountBalance.php @@ -7,17 +7,7 @@ use App\Models\Banking\Account; class AccountBalance extends Widget { - public function getDefaultName() - { - return trans('widgets.account_balance'); - } - - public function getDefaultSettings() - { - return [ - 'width' => 'col-md-4', - ]; - } + public $default_name = 'widgets.account_balance'; public function show() { diff --git a/app/Widgets/CashFlow.php b/app/Widgets/CashFlow.php index 612b11a9f..fbc9b5ece 100644 --- a/app/Widgets/CashFlow.php +++ b/app/Widgets/CashFlow.php @@ -13,17 +13,11 @@ class CashFlow extends Widget { use Currencies, DateTime; - public function getDefaultName() - { - return trans('widgets.cash_flow'); - } + public $default_name = 'widgets.cash_flow'; - public function getDefaultSettings() - { - return [ - 'width' => 'col-md-12', - ]; - } + public $default_settings = [ + 'width' => 'col-md-12', + ]; public function show() { diff --git a/app/Widgets/ExpensesByCategory.php b/app/Widgets/ExpensesByCategory.php index 76d916a77..f131d67db 100644 --- a/app/Widgets/ExpensesByCategory.php +++ b/app/Widgets/ExpensesByCategory.php @@ -7,17 +7,11 @@ use App\Models\Setting\Category; class ExpensesByCategory extends Widget { - public function getDefaultName() - { - return trans('widgets.expenses_by_category'); - } + public $default_name = 'widgets.expenses_by_category'; - public function getDefaultSettings() - { - return [ - 'width' => 'col-md-6', - ]; - } + public $default_settings = [ + 'width' => 'col-md-6', + ]; public function show() { diff --git a/app/Widgets/IncomeByCategory.php b/app/Widgets/IncomeByCategory.php index 23952184d..1d0dbf43d 100644 --- a/app/Widgets/IncomeByCategory.php +++ b/app/Widgets/IncomeByCategory.php @@ -7,17 +7,11 @@ use App\Models\Setting\Category; class IncomeByCategory extends Widget { - public function getDefaultName() - { - return trans('widgets.income_by_category'); - } + public $default_name = 'widgets.income_by_category'; - public function getDefaultSettings() - { - return [ - 'width' => 'col-md-6', - ]; - } + public $default_settings = [ + 'width' => 'col-md-6', + ]; public function show() { diff --git a/app/Widgets/LatestExpenses.php b/app/Widgets/LatestExpenses.php index 6a48391e5..ffdfb521e 100644 --- a/app/Widgets/LatestExpenses.php +++ b/app/Widgets/LatestExpenses.php @@ -7,17 +7,7 @@ use App\Models\Banking\Transaction; class LatestExpenses extends Widget { - public function getDefaultName() - { - return trans('widgets.latest_expenses'); - } - - public function getDefaultSettings() - { - return [ - 'width' => 'col-md-4', - ]; - } + public $default_name = 'widgets.latest_expenses'; public function show() { diff --git a/app/Widgets/LatestIncome.php b/app/Widgets/LatestIncome.php index 933c325e1..89334b9ee 100644 --- a/app/Widgets/LatestIncome.php +++ b/app/Widgets/LatestIncome.php @@ -7,17 +7,7 @@ use App\Models\Banking\Transaction; class LatestIncome extends Widget { - public function getDefaultName() - { - return trans('widgets.latest_income'); - } - - public function getDefaultSettings() - { - return [ - 'width' => 'col-md-4', - ]; - } + public $default_name = 'widgets.latest_income'; public function show() { diff --git a/app/Widgets/TotalExpenses.php b/app/Widgets/TotalExpenses.php index 7f633001b..b69ce3dfd 100644 --- a/app/Widgets/TotalExpenses.php +++ b/app/Widgets/TotalExpenses.php @@ -8,17 +8,11 @@ use App\Models\Purchase\Bill; class TotalExpenses extends Widget { - public function getDefaultName() - { - return trans('widgets.total_expenses'); - } + public $default_name = 'widgets.total_expenses'; - public function getDefaultSettings() - { - return [ - 'width' => 'col-md-4', - ]; - } + public $views = [ + 'header' => 'partials.widgets.stats_header', + ]; public function show() { diff --git a/app/Widgets/TotalIncome.php b/app/Widgets/TotalIncome.php index dc5e7c50d..e41ecc73d 100644 --- a/app/Widgets/TotalIncome.php +++ b/app/Widgets/TotalIncome.php @@ -8,17 +8,11 @@ use App\Models\Sale\Invoice; class TotalIncome extends Widget { - public function getDefaultName() - { - return trans('widgets.total_income'); - } + public $default_name = 'widgets.total_income'; - public function getDefaultSettings() - { - return [ - 'width' => 'col-md-4', - ]; - } + public $views = [ + 'header' => 'partials.widgets.stats_header', + ]; public function show() { diff --git a/app/Widgets/TotalProfit.php b/app/Widgets/TotalProfit.php index bae805d14..298e4a00f 100644 --- a/app/Widgets/TotalProfit.php +++ b/app/Widgets/TotalProfit.php @@ -9,17 +9,11 @@ use App\Models\Sale\Invoice; class TotalProfit extends Widget { - public function getDefaultName() - { - return trans('widgets.total_profit'); - } + public $default_name = 'widgets.total_profit'; - public function getDefaultSettings() - { - return [ - 'width' => 'col-md-4', - ]; - } + public $views = [ + 'header' => 'partials.widgets.stats_header', + ]; public function show() { diff --git a/resources/views/partials/widgets/standard_header.blade.php b/resources/views/partials/widgets/standard_header.blade.php index 26af63eea..b56ee13d0 100644 --- a/resources/views/partials/widgets/standard_header.blade.php +++ b/resources/views/partials/widgets/standard_header.blade.php @@ -3,7 +3,7 @@