Skip to content

Badges reputations #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/Gamify/Points/ReplyCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@

namespace App\Gamify\Points;

use App\Models\User;
use QCod\Gamify\PointType;

class ReplyCreated extends PointType
{
public int $points = 2;

public function __construct($subject)
public User $author;

public function __construct($subject, $author)
{
$this->subject = $subject;
$this->author = $author;
}

public function payee()
{
return $this->getSubject()->author;
return $this->author;
}
}
5 changes: 4 additions & 1 deletion app/Http/Controllers/Api/ReplyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function store(CreateReplyRequest $request): ReplyResource
$reply->to($target);
$reply->save();

givePoint(new ReplyCreated($target), $author);
$author->givePoint(new ReplyCreated($target, $author));

// On envoie un event pour une nouvelle réponse à tous les abonnés de la discussion
event(new CommentWasAdded($reply, $target));
Expand Down Expand Up @@ -79,6 +79,9 @@ public function delete(int $id): JsonResponse
{
/** @var Reply $reply */
$reply = Reply::findOrFail($id);

undoPoint(new ReplyCreated($reply->replyAble, $reply->author));

$reply->delete();

return response()->json(['message' => 'Commentaire supprimé avec succès']);
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Livewire/Forum/CreateReply.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public function save()
$reply->to($this->thread);
$reply->save();

event(new ReplyWasCreated($reply));
givePoint(new ReplyCreated($this->thread, Auth::user()));

givePoint(new ReplyCreated($this->thread));
event(new ReplyWasCreated($reply));

session()->flash('status', 'Réponse ajoutée avec succès!');

Expand Down