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 @@ -47,7 +47,7 @@ public function store(CreateReplyRequest $request): ReplyResource
4747 $ reply ->to ($ target );
4848 $ reply ->save ();
4949
50- givePoint (new ReplyCreated ($ target) , $ author );
50+ $ author -> givePoint (new ReplyCreated ($ target , $ author) );
5151
5252 // On envoie un event pour une nouvelle réponse à tous les abonnés de la discussion
5353 event (new CommentWasAdded ($ reply , $ target ));
@@ -79,6 +79,9 @@ public function delete(int $id): JsonResponse
7979 {
8080 /** @var Reply $reply */
8181 $ reply = Reply::findOrFail ($ id );
82+
83+ undoPoint (new ReplyCreated ($ reply ->replyAble , $ reply ->author ));
84+
8285 $ reply ->delete ();
8386
8487 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