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.
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
class CourseContentEvaluation extends SoftDeletesModel
|
|
|
|
|
{
|
|
|
|
|
protected $casts = ['audience_course_ids' => 'array'];
|
|
|
|
|
|
|
|
|
|
public function participationError($userId): ?string
|
|
|
|
|
{
|
|
|
|
|
if ($this->end_time && strtotime($this->end_time) <= time()) return '当前问卷已截止';
|
|
|
|
|
if ($this->audience_course_ids && !CourseSign::where('user_id', $userId)->whereIn('course_id', $this->audience_course_ids)->where('status', 1)->exists()) return '您还未报名相关课程';
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected $appends = ['course_content'];
|
|
|
|
|
|
|
|
|
|
public function getCourseContentAttribute()
|
|
|
|
|
{
|
|
|
|
|
if (empty($this->course_content_id)) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
$course_content_id = explode(',', $this->course_content_id);
|
|
|
|
|
return CourseContent::whereIn('id', $course_content_id)->get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function course()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Course::class, 'course_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function courseContentEvaluationAsks()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(CourseContentEvaluationAsk::class, 'course_content_evaluation_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function courseContentEvaluationForms()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(CourseContentEvaluationForm::class, 'course_content_evaluation_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|