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.
56 lines
1.2 KiB
56 lines
1.2 KiB
<?php
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
class CourseContent extends SoftDeletesModel
|
|
{
|
|
protected $casts = ['publicize_ids' => 'json'];
|
|
|
|
protected $appends = ['publicize'];
|
|
|
|
public function getPublicizeAttribute($value)
|
|
{
|
|
if (empty($this->publicize_ids)) return [];
|
|
return Upload::whereIn('id', $this->publicize_ids)->get();
|
|
}
|
|
|
|
public function course()
|
|
{
|
|
return $this->hasOne(Course::class, 'id', 'course_id');
|
|
}
|
|
|
|
public function coursePeriod()
|
|
{
|
|
return $this->hasOne(CoursePeriod::class, 'id', 'course_period_id');
|
|
}
|
|
|
|
public function courseSetting()
|
|
{
|
|
return $this->hasOne(CourseSetting::class, 'id', 'course_setting_id');
|
|
}
|
|
|
|
public function teacher()
|
|
{
|
|
return $this->hasOne(Teacher::class, 'id', 'teacher_id');
|
|
}
|
|
|
|
public function courseKeeps()
|
|
{
|
|
return $this->hasMany(CourseKeep::class, 'course_content_id', 'id');
|
|
}
|
|
|
|
public function courseSigns()
|
|
{
|
|
return $this->hasMany(CourseSign::class, 'course_id', 'course_id');
|
|
}
|
|
|
|
public function courseContentEvaluation()
|
|
{
|
|
return $this->hasOne(CourseContentEvaluation::class, 'course_content_id', 'id');
|
|
}
|
|
|
|
}
|
|
|