where($where)->count(); $list = $screen_mud->where($where)->page($get['page'], $get['limit'])->select(); foreach ($list as &$item) { $item['create_time'] = date('Y-m-d H:i:s', $item['create_time']); if ($item['is_show'] == 1) { $item['is_show_text'] = '启用'; } else { $item['is_show_text'] = '停用'; } } return ['count' => $count, 'lists' => $list]; } /** * Desc: 添加泥料 * @param $post array * @return boolean */ public static function addScreenMud($post) { $screen_mud = new ScreenMud(); $data = [ 'name' => $post['name'], 'is_show' => $post['is_show'], 'create_time' => time(), ]; return $screen_mud->save($data); } /** * Desc: 编辑泥料 * @param $post array * @return boolean */ public static function editScreenMud($post) { $screen_mud = new ScreenMud(); $data = [ 'name' => $post['name'], 'is_show' => $post['is_show'], 'update_time' => time(), ]; return $screen_mud->save($data, ['id' => $post['id'], 'del' => 0]); } /** * Desc: 删除泥料 * @param $id int * @return boolean */ public static function delScreenMud($id) { $screen_mud = new ScreenMud(); $data = [ 'update_time' => time(), 'del' => 1, ]; return $screen_mud->save($data, ['id' => $id, 'del' => 0]); } /** * Desc: 获取单条泥料 * @param $id int * @return boolean */ public static function getScreenMud($id = 0) { $where[] = ['del', '=', 0]; if ($id) { $where[] = ['id', '=', $id]; } $screen_mud = new ScreenMud(); return $screen_mud->where($where)->column('*', 'id'); } public static function switchStatus($post) { $data = [ 'is_show' => $post['is_show'], 'update_time' => time(), ]; return Db::name('screen_mud')->where(['del' => 0, 'id' => $post['id']])->update($data); } //获取泥料列表 public static function getScreenMudList(){ return Db::name('screen_mud')->where(['del'=>0])->field('id,name')->select(); } }