formatting
This commit is contained in:
parent
52bbd32bd8
commit
ebfc67709a
@ -17,7 +17,6 @@ use App\Models\Setting\Category;
|
||||
use App\Traits\Charts;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\SearchString;
|
||||
use App\Traits\Tailwind;
|
||||
use App\Traits\Translations;
|
||||
use App\Utilities\Date;
|
||||
use App\Utilities\Export as ExportHelper;
|
||||
@ -25,7 +24,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
abstract class Report
|
||||
{
|
||||
use Charts, DateTime, SearchString, Tailwind, Translations;
|
||||
use Charts, DateTime, SearchString, Translations;
|
||||
|
||||
public $model;
|
||||
|
||||
@ -236,9 +235,7 @@ abstract class Report
|
||||
foreach ($tmp_values as $id => $value) {
|
||||
$labels[$id] = $this->row_names[$table_key][$id];
|
||||
|
||||
$color = ($group == 'category') ? Category::withSubCategory()->find($id)?->color : '#' . dechex(rand(0x000000, 0xFFFFFF));
|
||||
|
||||
$colors[$id] = $this->getHexCodeOfTailwindClass($color);
|
||||
$colors[$id] = ($group == 'category') ? Category::withSubCategory()->find($id)?->colorHexCode : '#' . dechex(rand(0x000000, 0xFFFFFF));
|
||||
|
||||
$values[$id] = round(($value * 100 / $total), 0);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ use App\Models\Document\Document;
|
||||
use App\Relations\HasMany\Category as HasMany;
|
||||
use App\Scopes\Category as Scope;
|
||||
use App\Traits\Categories;
|
||||
use App\Traits\Tailwind;
|
||||
use App\Traits\Transactions;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@ -15,7 +16,7 @@ use Illuminate\Database\Eloquent\Model as EloquentModel;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use Categories, HasFactory, Transactions;
|
||||
use Categories, HasFactory, Tailwind, Transactions;
|
||||
|
||||
public const INCOME_TYPE = 'income';
|
||||
public const EXPENSE_TYPE = 'expense';
|
||||
@ -217,6 +218,14 @@ class Category extends Model
|
||||
return $query->withoutGlobalScope(new Scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hex code of the color.
|
||||
*/
|
||||
public function getColorHexCodeAttribute(): string
|
||||
{
|
||||
return $this->getHexCodeOfTailwindClass($this->color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the line actions.
|
||||
*
|
||||
|
@ -3,13 +3,10 @@
|
||||
namespace App\Traits;
|
||||
|
||||
use Akaunting\Apexcharts\Chart;
|
||||
use App\Traits\Tailwind;
|
||||
use Balping\JsonRaw\Raw;
|
||||
|
||||
trait Charts
|
||||
{
|
||||
use Tailwind;
|
||||
|
||||
public $bar = [
|
||||
'colors' => [],
|
||||
'labels' => [],
|
||||
@ -37,8 +34,6 @@ trait Charts
|
||||
$label .= ' - ' . $description;
|
||||
}
|
||||
|
||||
$color = $this->getHexCodeOfTailwindClass($color);
|
||||
|
||||
$this->addToDonut($color, $label, $amount);
|
||||
}
|
||||
|
||||
@ -74,8 +69,6 @@ trait Charts
|
||||
|
||||
public function addToBar($color, $label, $value)
|
||||
{
|
||||
$color = $this->getHexCodeOfTailwindClass($color);
|
||||
|
||||
$this->bar['colors'][] = $color;
|
||||
$this->bar['labels'][] = $label;
|
||||
$this->bar['values'][] = (int) $value;
|
||||
|
@ -22,7 +22,7 @@ class ExpensesByCategory extends Widget
|
||||
$amount += $transaction->getAmountConvertedToDefault();
|
||||
});
|
||||
|
||||
$this->addMoneyToDonut($category->color, $amount, $category->name);
|
||||
$this->addMoneyToDonut($category->colorHexCode, $amount, $category->name);
|
||||
});
|
||||
|
||||
$chart = $this->getDonutChart(trans_choice('general.expenses', 2), '100%', 300, 6);
|
||||
|
Loading…
x
Reference in New Issue
Block a user