1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace App\Services\Statistics;
- use App\Repositories\CategoryRepository;
- use App\Repositories\CategoryDistrictRepository;
- use Illuminate\Support\Facades\Cache;
- use Illuminate\Support\Facades\DB;
- class CategoryService
- {
- protected $categoryRepository;
- protected $categoryDistrictRepository;
- /**
- * CategoryService constructor.
- */
- public function __construct(CategoryRepository $categoryRepository, CategoryDistrictRepository $categoryDistrictRepository)
- {
- $this->categoryRepository = $categoryRepository;
- $this->categoryDistrictRepository = $categoryDistrictRepository;
- }
- public function getDistricts()
- {
- return $this->categoryDistrictRepository->getAllDistricts();
- }
- public function getCategories($filter_data = array())
- {
- $list = array();
- if ($filter_data) {
- $cates = $this->categoryRepository->getCategories();
- if ($cates) {
- foreach ($cates as $key => $val) {
- if ($key == 'AIX_wage') {
- foreach ($val as $k => $v) {
- if (config('aix.system.site_other.site_other.site_salary') == 1) {
- $cates[$key][$k]['demand'] = $v['k_demand'];
- } else {
- $cates[$key][$k]['demand'] = $v['c_demand'];
- }
- }
- }
- }
- }
- foreach ($filter_data as $k => $v) {
- if (array_key_exists($k, $cates)) {
- $list[$k] = array_slice($cates[$k], 0, 3);
- if ($v) {
- $list[$k] = array_slice($cates[$k], 0, $v, true);
- } else {
- $list[$k] = $cates[$k];
- }
- } else {
- $list[$k] = array();
- }
- }
- }
- return $list;
- }
- }
|