$params['farm_id'], 'fence_house_name' => $params['fence_house_name'], 'animal_type' => $params['animal_type'], 'fence_house_type' => $params['fence_house_type'], 'capacity' => $params['capacity'], 'master' => $params['master'], 'status' => $params['status'], 'qr_code' => $params['qr_code'], ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑 * @param array $params * @return bool * @author likeadmin * @date 2024/01/10 15:15 */ public static function edit(array $params): bool { Db::startTrans(); try { FenceHouse::where('id', $params['id'])->update([ 'farm_id' => $params['farm_id'], 'fence_house_name' => $params['fence_house_name'], 'animal_type' => $params['animal_type'], 'fence_house_type' => $params['fence_house_type'], 'capacity' => $params['capacity'], 'master' => $params['master'], 'status' => $params['status'], 'qr_code' => $params['qr_code'], ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除 * @param array $params * @return bool * @author likeadmin * @date 2024/01/10 15:15 */ public static function delete(array $params): bool { return FenceHouse::destroy($params['id']); } /** * @notes 获取详情 * @param $params * @return array * @author likeadmin * @date 2024/01/10 15:15 */ public static function detail($params): array { return FenceHouse::findOrEmpty($params['id'])->toArray(); } }