akaunting/app/Traits/Categories.php

35 lines
721 B
PHP
Raw Normal View History

2021-02-18 11:54:01 +03:00
<?php
namespace App\Traits;
2022-06-01 10:15:55 +03:00
use App\Models\Setting\Category;
2021-02-18 11:54:01 +03:00
use Illuminate\Support\Str;
trait Categories
{
public function getCategoryTypes()
{
$types = [];
$configs = config('type.category');
foreach ($configs as $type => $attr) {
$plural_type = Str::plural($type);
$name = $attr['translation']['prefix'] . '.' . $plural_type;
if (!empty($attr['alias'])) {
$name = $attr['alias'] . '::' . $name;
}
$types[$type] = trans_choice($name, 1);
}
return $types;
}
2022-06-01 10:15:55 +03:00
public function getCategoryWithoutChildren($id)
{
return Category::getWithoutChildren()->find($id);;
}
2021-02-18 11:54:01 +03:00
}