Skip to content

Commit

Permalink
Auto upvote own feature
Browse files Browse the repository at this point in the history
  • Loading branch information
spitfire305 committed May 31, 2024
1 parent 3a2cf5e commit 6e175d6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/Livewire/Roadmap/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Enums\FeatureStatus;
use App\Models\Feature;
use App\Models\FeatureVote;
use App\Models\FeatureFile;
use Livewire\Attributes\Validate;
use Livewire\Component;
Expand Down Expand Up @@ -41,6 +42,16 @@ public function save()
$feat->status_id = FeatureStatus::Draft;
$feat->save();

if (!auth()->user()->can('vote', $feat)) {
/** @var FeatureVote $vote */
$vote = new FeatureVote;
$vote->feature_id = $feat->id;
$vote->user_id = auth()->user()->id;
$vote->save();
$feat->upvote_count++;
$feat->updateQuietly();
}

NewFeatureEmailJob::dispatch($feat);

if ($this->file) {
Expand Down

0 comments on commit 6e175d6

Please sign in to comment.