@@ -53,29 +53,15 @@ public function instantSave()
53
53
54
54
public function sortEnvironmentVariables ()
55
55
{
56
- if ($ this ->resource ->type () === 'application ' ) {
57
- $ this ->resource ->load (['environment_variables ' , 'environment_variables_preview ' ]);
58
- } else {
59
- $ this ->resource ->load (['environment_variables ' ]);
60
- }
61
-
62
- $ sortBy = data_get ($ this ->resource , 'settings.is_env_sorting_enabled ' ) ? 'key ' : 'order ' ;
63
-
64
- $ sortFunction = function ($ variables ) use ($ sortBy ) {
65
- if (! $ variables ) {
66
- return $ variables ;
56
+ if (! data_get ($ this ->resource , 'settings.is_env_sorting_enabled ' )) {
57
+ if ($ this ->resource ->environment_variables ) {
58
+ $ this ->resource ->environment_variables = $ this ->resource ->environment_variables ->sortBy ('order ' )->values ();
67
59
}
68
- if ($ sortBy === 'key ' ) {
69
- return $ variables ->sortBy (function ($ item ) {
70
- return strtolower ($ item ->key );
71
- }, SORT_NATURAL | SORT_FLAG_CASE )->values ();
72
- } else {
73
- return $ variables ->sortBy ('order ' )->values ();
74
- }
75
- };
76
60
77
- $ this ->resource ->environment_variables = $ sortFunction ($ this ->resource ->environment_variables );
78
- $ this ->resource ->environment_variables_preview = $ sortFunction ($ this ->resource ->environment_variables_preview );
61
+ if ($ this ->resource ->environment_variables_preview ) {
62
+ $ this ->resource ->environment_variables_preview = $ this ->resource ->environment_variables_preview ->sortBy ('order ' )->values ();
63
+ }
64
+ }
79
65
80
66
$ this ->getDevView ();
81
67
}
@@ -121,6 +107,8 @@ public function submit($data = null)
121
107
$ this ->sortEnvironmentVariables ();
122
108
} catch (\Throwable $ e ) {
123
109
return handleError ($ e , $ this );
110
+ } finally {
111
+ $ this ->refreshEnvs ();
124
112
}
125
113
}
126
114
0 commit comments