master
cody 2 weeks ago
parent 8dd3e41de1
commit 5b504adad0

@ -212,9 +212,9 @@ class CourseSign extends SoftDeletesModel
public static function genban($start_date, $end_date, $course_ids = null, $retList = false)
{
$courseSignsQuery = self::getStudentList($start_date, $end_date, 1, $course_ids);
// 获取制定的课程id
// 获取需要统计跟班学员的课程
$genbanCourse = Course::whereHas('typeDetail', function ($query) {
$query->whereIn('id', [1, 3, 14]);
$query->whereIn('is_count_genban', 1);
})->get();
$courseSigns = $courseSignsQuery->whereHas('user', function ($query) {

@ -8,6 +8,16 @@ class CourseType extends SoftDeletesModel
{
const START_DATE = '2020-01-01 00:00:00';
protected $appends = ['is_count_genban_text'];
/**
* 是否统计跟班学员数文字
*/
public function getIsCountGenbanTextAttribute()
{
return ($this->attributes['is_count_genban'] ?? 1) == 1 ? '是' : '否';
}
public function courses()
{
return $this->hasMany(Course::class, 'type', 'id');

@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('course_types', function (Blueprint $table) {
$table->tinyInteger('is_count_genban')->default(0)->nullable()->comment('是否统计跟班学员数 0否 1是');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('course_types', function (Blueprint $table) {
$table->dropColumn('is_count_genban');
});
}
};
Loading…
Cancel
Save