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.

62 lines
1.4 KiB

6 months ago
<?php
namespace App\Models;
class CourseContent extends SoftDeletesModel
{
5 months ago
protected $casts = ['publicize_ids' => 'json', 'file_ids' => 'json'];
6 months ago
5 months ago
protected $appends = ['publicize', 'files'];
public function getFilesAttribute($value)
{
if (empty($this->file_ids)) return [];
return Upload::whereIn('id', $this->file_ids)->get();
}
6 months ago
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');
}
5 months ago
public function courseContentEvaluation()
5 months ago
{
5 months ago
return $this->hasOne(CourseContentEvaluation::class, 'course_content_id', 'id');
5 months ago
}
6 months ago
}