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.
83 lines
2.6 KiB
83 lines
2.6 KiB
<?php
|
|
|
|
/**
|
|
* +----------------------------------------------------------------------
|
|
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
|
* +----------------------------------------------------------------------
|
|
* | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
|
|
* +----------------------------------------------------------------------
|
|
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
|
* +----------------------------------------------------------------------
|
|
* | Author: CRMEB Team <admin@crmeb.com>
|
|
* +----------------------------------------------------------------------
|
|
*/
|
|
|
|
/**
|
|
* 年级管理
|
|
* @author crud自动生成代码
|
|
* @date 2023/10/13 10:40:08
|
|
*/
|
|
|
|
namespace app\dao\crud;
|
|
|
|
|
|
use app\dao\BaseDao;
|
|
use app\model\crud\SchoolGrade;
|
|
|
|
/**
|
|
* Class SchoolGradeDao
|
|
* @date 2023/10/13
|
|
* @package app\dao\crud
|
|
*/
|
|
class SchoolGradeDao extends BaseDao
|
|
{
|
|
|
|
/**
|
|
* 设置模型
|
|
* @return string
|
|
* @date 2023/10/13
|
|
*/
|
|
protected function setModel(): string
|
|
{
|
|
return SchoolGrade::class;
|
|
}
|
|
/**
|
|
* 搜索
|
|
* @param array $where
|
|
* @return \crmeb\basic\BaseModel
|
|
* @throws \ReflectionException
|
|
* @date {%DATE%}
|
|
*/
|
|
public function searchCrudModel(array $where = [], $field = ['*'], string $order = '', array $with = [])
|
|
{
|
|
return $this->getModel()->field($field)->when($order !== '', function ($query) use ($order) {
|
|
$query->order($order);
|
|
})->when($with, function ($query) use ($with) {
|
|
$query->with($with);
|
|
})->when(!empty($where['grade_name']), function ($query) use ($where) {
|
|
$query->whereLike('grade_name', '%' . $where['grade_name'] . '%');
|
|
})->when(!empty($where['create_time']), function ($query) use ($where) {
|
|
$query->whereBetween('create_time', $where['create_time']);
|
|
})->when(!empty($where['update_time']), function ($query) use ($where) {
|
|
$query->whereBetween('update_time', $where['update_time']);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 查询所有年级
|
|
*/
|
|
public function selectGradeDao()
|
|
{
|
|
$data = $this->getModel()->field('id as value, grade_name, school_name')->where('is_del', 0)->select();
|
|
return is_null($data) ? [] : $data->toArray();
|
|
}
|
|
|
|
/**
|
|
* 某一个学校下的全部年级
|
|
*/
|
|
public function selectSchoolGradeData($schoolId)
|
|
{
|
|
$data = $this->getModel()->field('id as grade_id, grade_name, school_name')->where('school_id', $schoolId)->where('is_del', 0)->select();
|
|
return is_null($data) ? [] : $data->toArray();
|
|
}
|
|
}
|
|
|