master
cody 3 weeks ago
parent 435f8d01eb
commit eb28e66b3b

@ -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[] = [

@ -146,18 +146,11 @@ class CourseSign extends SoftDeletesModel
/**
* 指定时间内的被投企业
*/
public static function yhInvested($start_date, $end_date, $status = null, $course_ids = null)
public static function yhInvested($start_date, $end_date)
{
$courseSignByType = CourseSign::whereDate('created_at', '>=', $start_date)
->whereDate('created_at', '<=', $end_date)
->where(function ($query) use ($status, $course_ids) {
if (isset($status)) {
$query->where('status', $status);
}
if (isset($course_ids)) {
$query->whereIn('course_id', $course_ids);
}
})->whereNotIn('status', [4, 5])
->whereNotIn('status', [4, 5])
->get();
return Company::whereHas('users', function ($query) use ($courseSignByType) {
$query->whereIn('id', $courseSignByType->pluck('user_id'));

Loading…
Cancel
Save