$params['name'], 'type' => $params['type'], 'status' => $params['status'] ?? 1, 'sort' => $params['sort'] ?? 0 ]); } /** * @notes 编辑农耕分类 * @param array $params * @return bool * @author heshihu * @date 2022/2/21 17:50 */ public static function edit(array $params) : bool { try { AgriculturalMachineryServiceCategory::update([ 'id' => $params['id'], 'name' => $params['name'], 'status' => $params['status'] ?? 1, 'sort' => $params['sort'] ?? 0 ]); return true; } catch (\Exception $e) { self::setError($e->getMessage()); return false; } } /** * @notes 删除农耕分类 * @param array $params * @author heshihu * @date 2022/2/21 17:52 */ public static function delete(array $params) { AgriculturalMachineryServiceCategory::destroy($params['id']); } /** * @notes 查看农耕分类详情 * @param $params * @return array * @author heshihu * @date 2022/2/21 17:54 */ public static function detail($params) : array { return AgriculturalMachineryServiceCategory::findOrEmpty($params['id'])->toArray(); } /** * @notes 更改农耕分类状态 * @param array $params * @return bool * @author heshihu * @date 2022/2/21 18:04 */ public static function updateStatus(array $params) { AgriculturalMachineryServiceCategory::update([ 'id' => $params['id'], 'status' => $params['status'] ]); return true; } /** * @notes 有效农耕分类数据 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author 段誉 * @date 2022/10/13 10:53 */ public static function getValidCateData($get) { $list = AgriculturalMachineryServiceCategory::where(['status' => YesNoEnum::YES,'type'=>$get['type']]) ->field('id,name') ->order(['sort' => 'desc', 'id' => 'desc']) ->select() ->toArray(); return $list; } }