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 2
2
3
3
namespace App \Gamify \Points ;
4
4
5
+ use App \Models \User ;
5
6
use QCod \Gamify \PointType ;
6
7
7
8
class ReplyCreated extends PointType
8
9
{
9
10
public int $ points = 2 ;
10
11
11
- public function __construct ($ subject )
12
+ public User $ author ;
13
+
14
+ public function __construct ($ subject , $ author )
12
15
{
13
16
$ this ->subject = $ subject ;
17
+ $ this ->author = $ author ;
14
18
}
15
19
16
20
public function payee ()
17
21
{
18
- return $ this ->getSubject ()-> author ;
22
+ return $ this ->author ;
19
23
}
20
24
}
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ public function store(CreateReplyRequest $request): ReplyResource
48
48
$ reply ->to ($ target );
49
49
$ reply ->save ();
50
50
51
- givePoint (new ReplyCreated ($ target), Auth:: user ( ));
51
+ $ author -> givePoint (new ReplyCreated ($ target, $ author ));
52
52
53
53
// On envoie un event pour une nouvelle réponse à tous les abonnés de la discussion
54
54
event (new CommentWasAdded ($ reply , $ target ));
@@ -80,6 +80,9 @@ public function delete(int $id): JsonResponse
80
80
{
81
81
/** @var Reply $reply */
82
82
$ reply = Reply::findOrFail ($ id );
83
+
84
+ undoPoint (new ReplyCreated ($ reply ->replyAble , $ reply ->author ));
85
+
83
86
$ reply ->delete ();
84
87
85
88
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()
40
40
$ reply ->to ($ this ->thread );
41
41
$ reply ->save ();
42
42
43
- event (new ReplyWasCreated ( $ reply ));
43
+ givePoint (new ReplyCreated ( $ this -> thread , Auth:: user () ));
44
44
45
- givePoint (new ReplyCreated ( $ this -> thread ));
45
+ event (new ReplyWasCreated ( $ reply ));
46
46
47
47
session ()->flash ('status ' , 'Réponse ajoutée avec succès! ' );
48
48
You can’t perform that action at this time.
0 commit comments