From 756b17164736031a1c20f0a6a638305d357fa4a9 Mon Sep 17 00:00:00 2001 From: HolgerHatGarKeineNode Date: Fri, 10 Mar 2023 23:50:37 +0100 Subject: [PATCH] voting added --- .../ProjectProposal/ProjectProposalVoting.php | 1 + app/Models/ProjectProposal.php | 6 ++++++ resources/lang/de.json | 5 +++-- resources/lang/en.json | 3 ++- resources/lang/es.json | 3 ++- resources/lang/fr.json | 3 ++- resources/lang/hr.json | 3 ++- resources/lang/it.json | 3 ++- resources/lang/mk.json | 3 ++- resources/lang/pl.json | 3 ++- resources/lang/pt.json | 3 ++- resources/lang/sv.json | 3 ++- resources/lang/tr.json | 3 ++- .../project-proposal-voting.blade.php | 15 +++++++++++++++ 14 files changed, 45 insertions(+), 12 deletions(-) diff --git a/app/Http/Livewire/ProjectProposal/ProjectProposalVoting.php b/app/Http/Livewire/ProjectProposal/ProjectProposalVoting.php index cbbd326e..98c9731b 100644 --- a/app/Http/Livewire/ProjectProposal/ProjectProposalVoting.php +++ b/app/Http/Livewire/ProjectProposal/ProjectProposalVoting.php @@ -38,6 +38,7 @@ class ProjectProposalVoting extends Component public function mount() { + $this->projectProposal->load('votes'); $vote = Vote::query() ->where('user_id', auth()->id()) ->where('project_proposal_id', $this->projectProposal->id) diff --git a/app/Models/ProjectProposal.php b/app/Models/ProjectProposal.php index 6f9cab83..3a36e816 100644 --- a/app/Models/ProjectProposal.php +++ b/app/Models/ProjectProposal.php @@ -5,6 +5,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; use Spatie\Image\Manipulations; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; @@ -64,4 +65,9 @@ class ProjectProposal extends Model implements HasMedia { return $this->belongsTo(User::class); } + + public function votes(): HasMany + { + return $this->hasMany(Vote::class); + } } diff --git a/resources/lang/de.json b/resources/lang/de.json index f0bc8cd6..4c93adbd 100644 --- a/resources/lang/de.json +++ b/resources/lang/de.json @@ -816,6 +816,7 @@ "Other voters": "Alle anderen", "Submit a project proposal and let the community vote on it through the elected voters. All other community members can also vote.": "", "Submitted by": "Übermittelt von", - "This project requires": "Dieses Projekt benötigt/beantragt", - "sats": "sats" + "This project requires": "Dieses Projekt benötigt\/beantragt", + "sats": "sats", + "Your vote": "Deine Stimme" } diff --git a/resources/lang/en.json b/resources/lang/en.json index 7dabc247..d7a10430 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -814,5 +814,6 @@ "Submit a project proposal and let the community vote on it through the elected voters. All other community members can also vote.": "", "Submitted by": "", "This project requires": "", - "sats": "" + "sats": "", + "Your vote": "" } \ No newline at end of file diff --git a/resources/lang/es.json b/resources/lang/es.json index ff6d173c..24a17c4d 100644 --- a/resources/lang/es.json +++ b/resources/lang/es.json @@ -814,5 +814,6 @@ "Submit a project proposal and let the community vote on it through the elected voters. All other community members can also vote.": "", "Submitted by": "", "This project requires": "", - "sats": "" + "sats": "", + "Your vote": "" } \ No newline at end of file diff --git a/resources/lang/fr.json b/resources/lang/fr.json index 462e4f42..67a70569 100644 --- a/resources/lang/fr.json +++ b/resources/lang/fr.json @@ -815,5 +815,6 @@ "Submit a project proposal and let the community vote on it through the elected voters. All other community members can also vote.": "", "Submitted by": "", "This project requires": "", - "sats": "" + "sats": "", + "Your vote": "" } \ No newline at end of file diff --git a/resources/lang/hr.json b/resources/lang/hr.json index b3617c8f..4d64124c 100644 --- a/resources/lang/hr.json +++ b/resources/lang/hr.json @@ -815,5 +815,6 @@ "Submit a project proposal and let the community vote on it through the elected voters. All other community members can also vote.": "", "Submitted by": "", "This project requires": "", - "sats": "" + "sats": "", + "Your vote": "" } \ No newline at end of file diff --git a/resources/lang/it.json b/resources/lang/it.json index 13f2c315..71aaa5e5 100644 --- a/resources/lang/it.json +++ b/resources/lang/it.json @@ -815,5 +815,6 @@ "Submit a project proposal and let the community vote on it through the elected voters. All other community members can also vote.": "", "Submitted by": "", "This project requires": "", - "sats": "" + "sats": "", + "Your vote": "" } \ No newline at end of file diff --git a/resources/lang/mk.json b/resources/lang/mk.json index 9614bf99..c90e7248 100644 --- a/resources/lang/mk.json +++ b/resources/lang/mk.json @@ -815,5 +815,6 @@ "Submit a project proposal and let the community vote on it through the elected voters. All other community members can also vote.": "", "Submitted by": "", "This project requires": "", - "sats": "" + "sats": "", + "Your vote": "" } \ No newline at end of file diff --git a/resources/lang/pl.json b/resources/lang/pl.json index 2667113a..9a192d39 100644 --- a/resources/lang/pl.json +++ b/resources/lang/pl.json @@ -815,5 +815,6 @@ "Submit a project proposal and let the community vote on it through the elected voters. All other community members can also vote.": "", "Submitted by": "", "This project requires": "", - "sats": "" + "sats": "", + "Your vote": "" } \ No newline at end of file diff --git a/resources/lang/pt.json b/resources/lang/pt.json index 56e9bf9a..336f3157 100644 --- a/resources/lang/pt.json +++ b/resources/lang/pt.json @@ -815,5 +815,6 @@ "Submit a project proposal and let the community vote on it through the elected voters. All other community members can also vote.": "", "Submitted by": "", "This project requires": "", - "sats": "" + "sats": "", + "Your vote": "" } \ No newline at end of file diff --git a/resources/lang/sv.json b/resources/lang/sv.json index 92301fb1..2dfa7f66 100644 --- a/resources/lang/sv.json +++ b/resources/lang/sv.json @@ -777,5 +777,6 @@ "Submit a project proposal and let the community vote on it through the elected voters. All other community members can also vote.": "", "Submitted by": "", "This project requires": "", - "sats": "" + "sats": "", + "Your vote": "" } \ No newline at end of file diff --git a/resources/lang/tr.json b/resources/lang/tr.json index 66366b78..8dfa6e89 100644 --- a/resources/lang/tr.json +++ b/resources/lang/tr.json @@ -789,5 +789,6 @@ "Submit a project proposal and let the community vote on it through the elected voters. All other community members can also vote.": "", "Submitted by": "", "This project requires": "", - "sats": "" + "sats": "", + "Your vote": "" } \ No newline at end of file diff --git a/resources/views/livewire/project-proposal/project-proposal-voting.blade.php b/resources/views/livewire/project-proposal/project-proposal-voting.blade.php index d9c881ca..d6cb7f89 100644 --- a/resources/views/livewire/project-proposal/project-proposal-voting.blade.php +++ b/resources/views/livewire/project-proposal/project-proposal-voting.blade.php @@ -66,6 +66,21 @@ No, don't support it! +
+ {{ __('Your vote') }}: + @php + $myVote = $projectProposal->votes->where('user_id', auth()->id())->first(); + @endphp + @if($myVote && $myVote->value) + {{ __('Yes') }} + @endif + @if($myVote && !$myVote->value) + {{ __('No') }} + @endif + @if(!$myVote) + {{ __('not voted yet') }} + @endif +