File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 22
33namespace App \Gamify \Points ;
44
5+ use App \Models \User ;
56use QCod \Gamify \PointType ;
67
78class ReplyCreated extends PointType
89{
910 public int $ points = 2 ;
1011
11- public function __construct ($ subject )
12+ public User $ author ;
13+
14+ public function __construct ($ subject , $ author )
1215 {
1316 $ this ->subject = $ subject ;
17+ $ this ->author = $ author ;
1418 }
1519
1620 public function payee ()
1721 {
18- return $ this ->getSubject ()-> author ;
22+ return $ this ->author ;
1923 }
2024}
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ public function store(CreateReplyRequest $request): ReplyResource
4848 $ reply ->to ($ target );
4949 $ reply ->save ();
5050
51- givePoint (new ReplyCreated ($ target), Auth:: user ( ));
51+ $ author -> givePoint (new ReplyCreated ($ target, $ author ));
5252
5353 // On envoie un event pour une nouvelle réponse à tous les abonnés de la discussion
5454 event (new CommentWasAdded ($ reply , $ target ));
@@ -80,6 +80,9 @@ public function delete(int $id): JsonResponse
8080 {
8181 /** @var Reply $reply */
8282 $ reply = Reply::findOrFail ($ id );
83+
84+ undoPoint (new ReplyCreated ($ reply ->replyAble , $ reply ->author ));
85+
8386 $ reply ->delete ();
8487
8588 return response ()->json (['message ' => 'Commentaire supprimé avec succès ' ]);
Original file line number Diff line number Diff line change @@ -40,9 +40,9 @@ public function save()
4040 $ reply ->to ($ this ->thread );
4141 $ reply ->save ();
4242
43- event (new ReplyWasCreated ( $ reply ));
43+ givePoint (new ReplyCreated ( $ this -> thread , Auth:: user () ));
4444
45- givePoint (new ReplyCreated ( $ this -> thread ));
45+ event (new ReplyWasCreated ( $ reply ));
4646
4747 session ()->flash ('status ' , 'Réponse ajoutée avec succès! ' );
4848
You can’t perform that action at this time.
0 commit comments