|
|
|
|
@ -219,7 +219,7 @@ class OtherController extends CommonController
|
|
|
|
|
*/
|
|
|
|
|
public function coursesHome()
|
|
|
|
|
{
|
|
|
|
|
$start_date = request('start_date', '2020-01-01');
|
|
|
|
|
$start_date = request('start_date', CourseType::START_DATE);
|
|
|
|
|
$end_date = request('end_date', date('Y-m-d'));
|
|
|
|
|
$course_type_id = request('course_type_id', '');
|
|
|
|
|
if ($course_type_id) {
|
|
|
|
|
@ -230,10 +230,7 @@ class OtherController extends CommonController
|
|
|
|
|
$course_type_id = CourseType::pluck('id')->toArray();
|
|
|
|
|
}
|
|
|
|
|
// 课程
|
|
|
|
|
$courses = Course::whereIn('type', $course_type_id)
|
|
|
|
|
// ->where('start_date', '<=', $end_date)
|
|
|
|
|
// ->where('start_date', '>=', $start_date)
|
|
|
|
|
->get();
|
|
|
|
|
$courses = Course::whereIn('type', $course_type_id)->get();
|
|
|
|
|
// 被投企业数
|
|
|
|
|
$list['course_signs_invested'] = CourseSign::yhInvested($start_date, $end_date);
|
|
|
|
|
// 报名人数
|
|
|
|
|
@ -246,19 +243,13 @@ class OtherController extends CommonController
|
|
|
|
|
$calendar = Calendar::whereIn('course_id', $courses->pluck('id'))->whereBetween('date', [$start_date, $end_date])->get();
|
|
|
|
|
$list['course_total'] = $calendar->count();
|
|
|
|
|
// 开课天数
|
|
|
|
|
$list['course_day_total'] = $calendar->sum(function ($course) {
|
|
|
|
|
$start = Carbon::parse($course->start_time);
|
|
|
|
|
$end = Carbon::parse($course->end_time);
|
|
|
|
|
return $end->diffInDays($start) + 1; // 包含起始和结束日期
|
|
|
|
|
});
|
|
|
|
|
$list['course_day_total'] = $calendar->sum('days');
|
|
|
|
|
// 课程分类明细统计
|
|
|
|
|
$courseTypesSum = [];
|
|
|
|
|
$courseTypes = CourseType::whereIn('id', $course_type_id)->get();
|
|
|
|
|
foreach ($courseTypes as $courseType) {
|
|
|
|
|
// 获取课程
|
|
|
|
|
$courses2 = Course::where('type', $courseType->id)
|
|
|
|
|
// ->where('start_date', '<=', $end_date)
|
|
|
|
|
// ->where('start_date', '>=', $start_date)
|
|
|
|
|
->get();
|
|
|
|
|
foreach ($courses2 as $course) {
|
|
|
|
|
$courseTypesSum[] = [
|
|
|
|
|
|