4
4
5
5
namespace App \Livewire \Components \Slideovers ;
6
6
7
- use App \Actions \Forum \SubscribeToThreadAction ;
8
- use App \Events \ ThreadWasCreated ;
7
+ use App \Actions \Forum \CreateThreadAction ;
8
+ use App \Actions \ Forum \ UpdateThreadAction ;
9
9
use App \Exceptions \UnverifiedUserException ;
10
- use App \Gamify \Points \ThreadCreated ;
11
10
use App \Livewire \Traits \WithAuthenticatedUser ;
12
11
use App \Models \Thread ;
13
12
use Filament \Forms ;
@@ -122,18 +121,11 @@ public function save(): void
122
121
123
122
$ validated = $ this ->form ->getState ();
124
123
125
- if ($ this ->thread ?->id) {
126
- $ this ->thread ->update ($ validated );
127
- $ this ->form ->model ($ this ->thread )->saveRelationships ();
128
- } else {
129
- $ thread = Thread::query ()->create ($ validated );
130
- $ this ->form ->model ($ thread )->saveRelationships ();
131
-
132
- app (SubscribeToThreadAction::class)->execute ($ thread );
124
+ $ thread = ($ this ->thread ?->id)
125
+ ? app (UpdateThreadAction::class)->execute ($ validated , $ this ->thread ->id )
126
+ : app (CreateThreadAction::class)->execute ($ validated );
133
127
134
- givePoint (new ThreadCreated ($ thread ));
135
- event (new ThreadWasCreated ($ thread ));
136
- }
128
+ $ this ->form ->model ($ thread )->saveRelationships ();
137
129
138
130
Notification::make ()
139
131
->title (
@@ -144,7 +136,7 @@ public function save(): void
144
136
->success ()
145
137
->send ();
146
138
147
- $ this ->redirect (route ('forum.show ' , ['thread ' => $ thread ?? $ this -> thread ]), navigate: true );
139
+ $ this ->redirect (route ('forum.show ' , ['thread ' => $ thread ]), navigate: true );
148
140
}
149
141
150
142
public function render (): View
0 commit comments