6
6
use Illuminate \Support \Facades \Auth ;
7
7
use Illuminate \Support \Facades \Hash ;
8
8
use Livewire \Component ;
9
+ use Spatie \Url \Url ;
9
10
10
11
class ServiceApplicationView extends Component
11
12
{
@@ -31,13 +32,7 @@ class ServiceApplicationView extends Component
31
32
32
33
public function updatedApplicationFqdn ()
33
34
{
34
- $ this ->application ->fqdn = str ($ this ->application ->fqdn )->replaceEnd (', ' , '' )->trim ();
35
- $ this ->application ->fqdn = str ($ this ->application ->fqdn )->replaceStart (', ' , '' )->trim ();
36
- $ this ->application ->fqdn = str ($ this ->application ->fqdn )->trim ()->explode (', ' )->map (function ($ domain ) {
37
- return str ($ domain )->trim ()->lower ();
38
- });
39
- $ this ->application ->fqdn = $ this ->application ->fqdn ->unique ()->implode (', ' );
40
- $ this ->application ->save ();
35
+
41
36
}
42
37
43
38
public function instantSave ()
@@ -83,6 +78,14 @@ public function mount()
83
78
public function submit ()
84
79
{
85
80
try {
81
+ $ this ->application ->fqdn = str ($ this ->application ->fqdn )->replaceEnd (', ' , '' )->trim ();
82
+ $ this ->application ->fqdn = str ($ this ->application ->fqdn )->replaceStart (', ' , '' )->trim ();
83
+ $ this ->application ->fqdn = str ($ this ->application ->fqdn )->trim ()->explode (', ' )->map (function ($ domain ) {
84
+ Url::fromString ($ domain , ['http ' , 'https ' ]);
85
+ return str ($ domain )->trim ()->lower ();
86
+ });
87
+ $ this ->application ->fqdn = $ this ->application ->fqdn ->unique ()->implode (', ' );
88
+
86
89
check_domain_usage (resource: $ this ->application );
87
90
$ this ->validate ();
88
91
$ this ->application ->save ();
@@ -92,10 +95,13 @@ public function submit()
92
95
} else {
93
96
$ this ->dispatch ('success ' , 'Service saved. ' );
94
97
}
98
+ $ this ->dispatch ('generateDockerCompose ' );
95
99
} catch (\Throwable $ e ) {
100
+ $ originalFqdn = $ this ->application ->getOriginal ('fqdn ' );
101
+ if ($ originalFqdn !== $ this ->application ->fqdn ) {
102
+ $ this ->application ->fqdn = $ originalFqdn ;
103
+ }
96
104
return handleError ($ e , $ this );
97
- } finally {
98
- $ this ->dispatch ('generateDockerCompose ' );
99
105
}
100
106
}
101
107
0 commit comments