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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
|
|
|
|
class Calendar extends SoftDeletesModel
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
protected $appends = ['is_publish_text', 'type_text', 'is_count_days_text', 'is_count_people_text'];
|
|
|
|
|
|
|
|
|
|
public function getIsPublishTextAttribute()
|
|
|
|
|
{
|
|
|
|
|
return $this->attributes['is_publish'] == 1 ? '是' : '否';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getTypeTextAttribute()
|
|
|
|
|
{
|
|
|
|
|
$array = [1=>'课程', 3=>'自定义事件', 4=>'资讯'];
|
|
|
|
|
return $array[$this->attributes['type']] ?? '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getIsCountDaysTextAttribute()
|
|
|
|
|
{
|
|
|
|
|
return ($this->attributes['is_count_days'] ?? 1) == 1 ? '是' : '否';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getIsCountPeopleTextAttribute()
|
|
|
|
|
{
|
|
|
|
|
return ($this->attributes['is_count_people'] ?? 1) == 1 ? '是' : '否';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function course()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(Course::class, 'id', 'course_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function courseContent()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(CourseContent::class, 'id', 'course_content_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function historyCourses()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(HistoryCourse::class, 'calendar_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|