You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
2.2 KiB
44 lines
2.2 KiB
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Models\Config;
|
|
use Illuminate\Support\Arr;
|
|
|
|
class DisplayController extends CommonController
|
|
{
|
|
public function dashboard(OtherController $statistics)
|
|
{
|
|
$data = $statistics->homeV2Data();
|
|
$coverage = json_decode(Config::where('key', 'threeCoverageItems')->orderBy('id', 'desc')->value('value') ?? '[]', true);
|
|
|
|
return $this->success([
|
|
'list' => Arr::only($data['list'], [
|
|
'schoolmate_total', 'schoolmate_year', 'course_signs_pass',
|
|
'course_signs_pass_unique', 'genban_total', 'company_invested_total',
|
|
]),
|
|
'suzhou' => collect($data['suzhou'])->map(fn ($area) => Arr::only($area, ['area', 'total', 'total_unique'])),
|
|
'country' => collect($data['country'])->map(fn ($area) => Arr::only($area, ['area', 'total'])),
|
|
'monthCourses' => collect($data['monthCourses'])->map(fn ($item) => [
|
|
'name' => data_get($item, 'title') ?: data_get($item, 'course.name', ''),
|
|
'location' => data_get($item, 'address') ?: data_get($item, 'course.address_detail', ''),
|
|
'teacher' => collect(data_get($item, 'course.teacher_detail'))->pluck('name')->filter()->implode('、'),
|
|
]),
|
|
'yearConfigs' => collect($data['yearConfigs'])->map(fn ($year) => [
|
|
'name' => data_get($year, 'name'),
|
|
'course_periods_total' => data_get($year, 'course_periods_total'),
|
|
'course_signs_unique_total' => data_get($year, 'course_signs_unique_total'),
|
|
'courseTypes' => collect(data_get($year, 'courseTypes'))->map(fn ($type) => [
|
|
'name' => data_get($type, 'name'),
|
|
'course_periods_total' => data_get($type, 'course_periods_total'),
|
|
'course_signs_total' => data_get($type, 'course_signs_total'),
|
|
])->values(),
|
|
])->values(),
|
|
'coverage' => collect(is_array($coverage) ? $coverage : [])
|
|
->filter(fn ($item) => is_array($item))
|
|
->map(fn ($item) => Arr::only($item, ['name', 'total', 'complete', 'unit']))
|
|
->values(),
|
|
]);
|
|
}
|
|
}
|