where("status", $value); } } /** * 搜索器:合同关系创建时间 * @param $value * @param $data */ public function searchCreatedAtAttr($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([["created_at", "between", [$start, $end]]]); } else if ($start > 0 && $end == 0) { $query->where([["created_at", ">=", $start]]); } else if ($start == 0 && $end > 0) { $query->where([["created_at", "<=", $end]]); } } /** * 搜索器:合同关系签署时间 * @param $value * @param $data */ public function searchSignTimeAttr($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([["sign_time", "between", [$start, $end]]]); } else if ($start > 0 && $end == 0) { $query->where([["sign_time", ">=", $start]]); } else if ($start == 0 && $end > 0) { $query->where([["sign_time", "<=", $end]]); } } public function contract(){ return $this->hasOne(Contract::class, 'id', 'contract_id')->joinType('left')->withField('contract_name,id')->bind(['contract_id_name'=>'contract_name']); } public function personnel(){ return $this->hasOne(Personnel::class, 'id', 'personnel_id')->joinType('left')->withField('name,id')->bind(['personnel_id_name'=>'name']); } }