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 @@ -47,7 +47,7 @@ public function store(CreateReplyRequest $request): ReplyResource
47
47
$ reply ->to ($ target );
48
48
$ reply ->save ();
49
49
50
- givePoint (new ReplyCreated ($ target) , $ author );
50
+ $ author -> givePoint (new ReplyCreated ($ target , $ author) );
51
51
52
52
// On envoie un event pour une nouvelle réponse à tous les abonnés de la discussion
53
53
event (new CommentWasAdded ($ reply , $ target ));
@@ -79,6 +79,9 @@ public function delete(int $id): JsonResponse
79
79
{
80
80
/** @var Reply $reply */
81
81
$ reply = Reply::findOrFail ($ id );
82
+
83
+ undoPoint (new ReplyCreated ($ reply ->replyAble , $ reply ->author ));
84
+
82
85
$ reply ->delete ();
83
86
84
87
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