2019-12-29 03:01:19 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Widgets;
|
|
|
|
|
|
|
|
use App\Abstracts\Widget;
|
|
|
|
use App\Models\Setting\Category;
|
|
|
|
|
|
|
|
class IncomeByCategory extends Widget
|
|
|
|
{
|
|
|
|
public function show()
|
|
|
|
{
|
2019-12-29 10:20:27 +03:00
|
|
|
Category::with('income_transacions')->type('income')->enabled()->each(function ($category) {
|
2019-12-29 03:01:19 +03:00
|
|
|
$amount = 0;
|
|
|
|
|
2019-12-30 12:30:30 +03:00
|
|
|
$transactions = $this->applyFilters($category->income_transacions())->get();
|
|
|
|
|
|
|
|
foreach ($transactions as $transacion) {
|
2019-12-29 03:01:19 +03:00
|
|
|
$amount += $transacion->getAmountConvertedToDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->addMoneyToDonut($category->color, $amount, $category->name);
|
|
|
|
});
|
|
|
|
|
|
|
|
$chart = $this->getDonutChart(trans_choice('general.incomes', 1), 0, 160, 6);
|
|
|
|
|
2019-12-31 02:20:10 +03:00
|
|
|
return $this->view('widgets.income_by_category', [
|
2019-12-29 03:01:19 +03:00
|
|
|
'chart' => $chart,
|
|
|
|
]);
|
|
|
|
}
|
2019-12-31 02:20:10 +03:00
|
|
|
|
|
|
|
public function getDefaultName()
|
|
|
|
{
|
|
|
|
return trans('widgets.income_by_category');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDefaultSettings()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'width' => 'col-md-6',
|
|
|
|
];
|
|
|
|
}
|
2019-12-29 03:01:19 +03:00
|
|
|
}
|