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.
105 lines
2.6 KiB
105 lines
2.6 KiB
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Course extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'code',
|
|
'code_prefix',
|
|
'title',
|
|
'course_system_dict_item_id',
|
|
'course_type_dict_item_id',
|
|
'teach_start_date',
|
|
'teach_end_date',
|
|
'location',
|
|
'teach_start_time',
|
|
'teach_end_time',
|
|
'recruit_targets',
|
|
'main_speakers',
|
|
'signup_start_date',
|
|
'signup_end_date',
|
|
'auto_add_teacher_dict_item_id',
|
|
'capacity',
|
|
'cover_media_id',
|
|
'promo_media_id',
|
|
'news_id',
|
|
'news_link_url',
|
|
'intro_html',
|
|
'signup_form_schema',
|
|
'progress_status',
|
|
'published',
|
|
'remark',
|
|
'sort',
|
|
];
|
|
|
|
protected $casts = [
|
|
'teach_start_date' => 'date',
|
|
'teach_end_date' => 'date',
|
|
'signup_start_date' => 'date',
|
|
'signup_end_date' => 'date',
|
|
'capacity' => 'integer',
|
|
'cover_media_id' => 'integer',
|
|
'promo_media_id' => 'integer',
|
|
'news_id' => 'integer',
|
|
'progress_status' => 'integer',
|
|
'published' => 'integer',
|
|
'sort' => 'integer',
|
|
'signup_form_schema' => 'array',
|
|
'recruit_targets' => 'array',
|
|
'main_speakers' => 'array',
|
|
];
|
|
|
|
public function courseSystemItem(): BelongsTo
|
|
{
|
|
return $this->belongsTo(DictItem::class, 'course_system_dict_item_id');
|
|
}
|
|
|
|
public function courseTypeItem(): BelongsTo
|
|
{
|
|
return $this->belongsTo(DictItem::class, 'course_type_dict_item_id');
|
|
}
|
|
|
|
public function autoAddTeacherItem(): BelongsTo
|
|
{
|
|
return $this->belongsTo(DictItem::class, 'auto_add_teacher_dict_item_id');
|
|
}
|
|
|
|
public function coverMedia(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CourseMedia::class, 'cover_media_id');
|
|
}
|
|
|
|
public function promoMedia(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CourseMedia::class, 'promo_media_id');
|
|
}
|
|
|
|
public function news(): BelongsTo
|
|
{
|
|
return $this->belongsTo(News::class);
|
|
}
|
|
|
|
public function sessions(): HasMany
|
|
{
|
|
return $this->hasMany(CourseSession::class);
|
|
}
|
|
|
|
public function signups(): HasMany
|
|
{
|
|
return $this->hasMany(CourseSignup::class);
|
|
}
|
|
|
|
public function checkinDays(): HasMany
|
|
{
|
|
return $this->hasMany(CourseCheckinDay::class);
|
|
}
|
|
}
|