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.4 KiB
105 lines
2.4 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\model\course_schedule;
|
|
|
|
use app\model\course\Course;
|
|
use app\model\personnel\Personnel;
|
|
use app\model\venue\Venue;
|
|
use core\base\BaseModel;
|
|
use think\model\concern\SoftDelete;
|
|
use think\model\relation\HasMany;
|
|
use think\model\relation\HasOne;
|
|
|
|
/**
|
|
* 课程安排模型
|
|
* Class CourseSchedule
|
|
* @package app\model\course_schedule
|
|
*/
|
|
class CourseSchedule extends BaseModel
|
|
{
|
|
|
|
use SoftDelete;
|
|
|
|
/**
|
|
* 数据表主键
|
|
* @var string
|
|
*/
|
|
protected $pk = 'id';
|
|
|
|
/**
|
|
* 模型名称
|
|
* @var string
|
|
*/
|
|
protected $name = 'course_schedule';
|
|
|
|
/**
|
|
* 定义软删除标记字段.
|
|
* @var string
|
|
*/
|
|
protected $deleteTime = 'deleted_at';
|
|
|
|
/**
|
|
* 定义软删除字段的默认值.
|
|
* @var int
|
|
*/
|
|
protected $defaultSoftDelete = 0;
|
|
|
|
protected $json = ['participants', 'student_ids'];
|
|
|
|
protected $jsonAssoc = true;
|
|
/**
|
|
* 搜索器:场地校区
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchCampusIdAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("campus_id", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:场地ID
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchVenueIdAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("venue_id", $value);
|
|
}
|
|
}
|
|
|
|
public function searchCourseDateAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("course_date", $value);
|
|
}
|
|
}
|
|
|
|
public function venue()
|
|
{
|
|
return $this->hasOne(Venue::class, 'id', 'venue_id');
|
|
}
|
|
|
|
public function coach()
|
|
{
|
|
return $this->hasOne(Personnel::class, 'id', 'coach_id');
|
|
}
|
|
|
|
public function course()
|
|
{
|
|
return $this->hasOne(Course::class, 'id', 'course_id');
|
|
}
|
|
|
|
}
|
|
|