attributes['is_publish'] == 1 ? '是' : '否'; } public function getTypeTextAttribute() { $array = [1=>'课程', 3=>'自定义事件', 4=>'资讯']; return $array[$this->attributes['type']] ?? ''; } public function course() { return $this->hasOne(Course::class, 'id', 'course_id'); } public function courseContent() { return $this->hasMany(CourseContent::class, 'id', 'course_content_id'); } }