master
cody 2 weeks ago
parent 1ce011e08b
commit 6a393097ba

@ -235,7 +235,7 @@ class OtherController extends CommonController
->orWhereBetween('end_time', [$start_date, $end_date]); ->orWhereBetween('end_time', [$start_date, $end_date]);
})->where(function ($query) use ($courses) { })->where(function ($query) use ($courses) {
if (request('course_type_id')) { if (request('course_type_id')) {
$query->whereIn('course_id', $courses->pluck('id')); $query->whereIn('course_type_id', request('course_type_id'));
} }
}); });
$list['course_total'] = (clone $calendar)->count(); $list['course_total'] = (clone $calendar)->count();
@ -732,7 +732,7 @@ class OtherController extends CommonController
$calendars = Calendar::whereBetween('date', [$start_date, $end_date]) $calendars = Calendar::whereBetween('date', [$start_date, $end_date])
->where(function ($query) use ($course_ids) { ->where(function ($query) use ($course_ids) {
if (request('course_type_id')) { if (request('course_type_id')) {
$query->whereIn('course_id', $course_ids); $query->whereIn('course_type_id', request('course_type_id'));
} }
})->where('is_count_days', 1) })->where('is_count_days', 1)
->with('course') ->with('course')

@ -47,5 +47,10 @@ class Calendar extends SoftDeletesModel
return $this->hasMany(HistoryCourse::class, 'calendar_id', 'id'); return $this->hasMany(HistoryCourse::class, 'calendar_id', 'id');
} }
public function courseType()
{
return $this->belongsTo(CourseType::class, 'course_type_id', 'id');
}
} }

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddCourseTypeIdToCalendarsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('calendars', function (Blueprint $table) {
$table->unsignedBigInteger('course_type_id')->nullable()->after('id')->comment('课程类型ID');
$table->index('course_type_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('calendars', function (Blueprint $table) {
$table->dropIndex(['course_type_id']);
$table->dropColumn('course_type_id');
});
}
}
Loading…
Cancel
Save