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.
142 lines
3.7 KiB
142 lines
3.7 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace addon\zhjw\app\model\schedules;
|
|
|
|
use core\base\BaseModel;
|
|
use think\model\concern\SoftDelete;
|
|
use think\model\relation\HasMany;
|
|
use think\model\relation\HasOne;
|
|
|
|
use addon\zhjw\app\model\staff\Staff;
|
|
|
|
use addon\zhjw\app\model\classes\Classes;
|
|
|
|
/**
|
|
* 排班管理模型
|
|
* Class Schedules
|
|
* @package addon\zhjw\app\model\schedules
|
|
*/
|
|
class Schedules extends BaseModel
|
|
{
|
|
|
|
use SoftDelete;
|
|
|
|
/**
|
|
* 数据表主键
|
|
* @var string
|
|
*/
|
|
protected $pk = 'id';
|
|
|
|
/**
|
|
* 模型名称
|
|
* @var string
|
|
*/
|
|
protected $name = 'zhjw_schedules';
|
|
|
|
/**
|
|
* 定义软删除标记字段.
|
|
* @var string
|
|
*/
|
|
protected $deleteTime = 'is_deleted';
|
|
|
|
/**
|
|
* 定义软删除字段的默认值.
|
|
* @var int
|
|
*/
|
|
protected $defaultSoftDelete = 0;
|
|
|
|
/**
|
|
* 搜索器:排班管理人员
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchStaffIdAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("staff_id", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:排班管理班级
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchClassIdAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("class_id", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:排班管理排班日期
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchDateTimeAttr($query, $value, $data)
|
|
{
|
|
$start = empty($value[0]) ? 0 : strtotime($value[0]);
|
|
$end = empty($value[1]) ? 0 : strtotime($value[1]);
|
|
if ($start > 0 && $end > 0) {
|
|
$query->where([["date_time", "between", [$start, $end]]]);
|
|
} else if ($start > 0 && $end == 0) {
|
|
$query->where([["date_time", ">=", $start]]);
|
|
} else if ($start == 0 && $end > 0) {
|
|
$query->where([["date_time", "<=", $end]]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:排班管理任务描述
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchTaskAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("task", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:排班管理添加时间
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchCreateTimeAttr($query, $value, $data)
|
|
{
|
|
$start = empty($value[0]) ? 0 : strtotime($value[0]);
|
|
$end = empty($value[1]) ? 0 : strtotime($value[1]);
|
|
if ($start > 0 && $end > 0) {
|
|
$query->where([["create_time", "between", [$start, $end]]]);
|
|
} else if ($start > 0 && $end == 0) {
|
|
$query->where([["create_time", ">=", $start]]);
|
|
} else if ($start == 0 && $end > 0) {
|
|
$query->where([["create_time", "<=", $end]]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function staff(){
|
|
return $this->hasOne(Staff::class, 'id', 'staff_id')->joinType('left')->withField('name,id')->bind(['staff_id_name'=>'name']);
|
|
}
|
|
|
|
public function classes(){
|
|
return $this->hasOne(Classes::class, 'id', 'class_id')->joinType('left')->withField('name,id')->bind(['class_id_name'=>'name']);
|
|
}
|
|
|
|
}
|
|
|