-
Notifications
You must be signed in to change notification settings - Fork 0
Resource edits tab #52
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
Changes from all commits
7431431
f12ee01
1a1a2e7
b570334
31660ff
ba51576
36714e2
c7716d9
16569d2
2ff30e2
b55ce3c
0c7cf91
1c3ca6f
8704e89
56ead55
d2d70cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,16 @@ | |
| use App\Http\Requests\StoreResourceReviewRequest; | ||
| use App\Models\ComputerScienceResource; | ||
| use App\Models\ResourceReview; | ||
| use App\Services\UpvoteService; | ||
| use Illuminate\Support\Facades\Auth; | ||
| use Illuminate\Support\Facades\Log; | ||
|
|
||
| class ResourceReviewController extends Controller | ||
| { | ||
| public function __construct( | ||
| protected UpvoteService $upvoteService, | ||
| ) {} | ||
|
|
||
| // Store the review on the resource | ||
| public function store(StoreResourceReviewRequest $request, ComputerScienceResource $computerScienceResource) | ||
| { | ||
|
|
@@ -58,6 +63,8 @@ public function store(StoreResourceReviewRequest $request, ComputerScienceResour | |
| 'review_id' => $review->id, | ||
| ]); | ||
|
|
||
| $this->upvoteService->upvote('review', $review->id); | ||
|
||
|
|
||
| return response()->json($review); | ||
| } | ||
|
|
||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The upvote call is made outside of the database transaction. If the upvote operation fails, the resource will still be created but without its automatic upvote. Consider moving the upvote call inside the transaction before the commit, or handle the failure scenario appropriately.