$params['land_id'], 'kind' => $params['kind'], 'breed' => $params['breed'], 'area' => $params['area'], 'user' => $params['user'], 'remark' => $params['remark'], 'status' => $params['status'], 'pic' => $params['pic'], 'qr_code' => $params['qr_code'], 'plant_date' => strtotime($params['plant_date']), ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑 * @param array $params * @return bool * @author likeadmin * @date 2023/11/23 11:32 */ public static function edit(array $params): bool { Db::startTrans(); try { LandPlant::where('id', $params['id'])->update([ 'land_id' => $params['land_id'], 'kind' => $params['kind'], 'breed' => $params['breed'], 'area' => $params['area'], 'user' => $params['user'], 'remark' => $params['remark'], 'status' => $params['status'], 'pic' => $params['pic'], 'qr_code' => $params['qr_code'], 'plant_date' => strtotime($params['plant_date']), ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除 * @param array $params * @return bool * @author likeadmin * @date 2023/11/23 11:32 */ public static function delete(array $params): bool { return LandPlant::destroy($params['id']); } /** * @notes 获取详情 * @param $params * @return array * @author likeadmin * @date 2023/11/23 11:32 */ public static function detail($params): array { return LandPlant::findOrEmpty($params['id'])->toArray(); } }