From 6e175d6bbb5fba37426798d4d8ca21c1f4c1ab46 Mon Sep 17 00:00:00 2001 From: Spitfire Date: Fri, 31 May 2024 11:40:34 -0600 Subject: [PATCH] Auto upvote own feature --- app/Livewire/Roadmap/Form.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Livewire/Roadmap/Form.php b/app/Livewire/Roadmap/Form.php index e9ea6b660c..d5a890cae5 100644 --- a/app/Livewire/Roadmap/Form.php +++ b/app/Livewire/Roadmap/Form.php @@ -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; @@ -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) {