* +---------------------------------------------------------------------- */ /** * 关联列表 * @author crud自动生成代码 * @date 2023/10/19 13:48:45 */ namespace app\dao\crud; use app\dao\BaseDao; use app\model\crud\SchoolClassIpc; /** * Class SchoolClassIpcDao * @date 2023/10/19 * @package app\dao\crud */ class SchoolClassIpcDao extends BaseDao { /** * 设置模型 * @return string * @date 2023/10/19 */ protected function setModel(): string { return SchoolClassIpc::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); }); } /** * 通过设备ID查询数据 */ public function selectDataByIotId($iot_id) { $resData = $this->getModel()->field('id')->where('iot_id', $iot_id)->where('is_del', 0)->find(); return is_null($resData) ? [] : $resData->toArray(); } /** * 通过班级ID查询数据 */ public function selectDataByClassId($class_id) { $resData = $this->getModel()->field('iot_id')->where('class_id', $class_id)->where('is_del', 0)->select(); return is_null($resData) ? [] : $resData->toArray(); } public function getThisModel() { return $this->getModel(); } }