diff --git a/app/Livewire/Forms/VoteForm.php b/app/Livewire/Forms/VoteForm.php new file mode 100644 index 0000000..9606b27 --- /dev/null +++ b/app/Livewire/Forms/VoteForm.php @@ -0,0 +1,12 @@ + [ + 'npub1pt0kw36ue3w2g4haxq3wgm6a2fhtptmzsjlc2j2vphtcgle72qesgpjyc6', + 'npub1gvqkjccl9urg93svaw60jqkk3ux8r3ycl5t3rlvc9uzjeu0agfuss8x8qy', + 'npub10t8npnmqhpwx9w8k232kess7gqtdlr6kqjemdzf8jnughwqd0gwsez0924', + 'npub1r8343wqpra05l3jnc4jud4xz7vlnyeslf7gfsty7ahpf92rhfmpsmqwym8', + 'npub17fqtu2mgf7zueq2kdusgzwr2lqwhgfl2scjsez77ddag2qx8vxaq3vnr8y', + ], +]; diff --git a/resources/views/pages/association/project-support/[ProjectProposal:slug].blade.php b/resources/views/pages/association/project-support/[ProjectProposal:slug].blade.php new file mode 100644 index 0000000..6028be4 --- /dev/null +++ b/resources/views/pages/association/project-support/[ProjectProposal:slug].blade.php @@ -0,0 +1,293 @@ + fn() => $projectProposal, + 'isAllowed' => false, + 'currentPubkey' => null, + 'currentPleb' => null, + 'reasons' => fn() + => Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->where('value', false) + ->get(), + 'ownVoteExists' => false, + 'boardVotes' => fn() + => Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->whereHas('einundzwanzigPleb', fn($q) => $q->whereIn('npub', config('einundzwanzig.config.current_board'))) + ->where('value', true) + ->get(), + 'otherVotes' => fn() + => Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->whereDoesntHave( + 'einundzwanzigPleb', + fn($q) => $q->whereIn('npub', config('einundzwanzig.config.current_board')), + ) + ->where('value', true) + ->get(), +]); + +on([ + 'nostrLoggedIn' => function ($pubkey) { + $this->currentPubkey = $pubkey; + $this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first(); + if ($this->currentPleb->association_status->value < 2) { + return $this->js('alert("Du bist hierzu nicht berechtigt.")'); + } + $this->isAllowed = true; + $this->ownVoteExists = Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->where('einundzwanzig_pleb_id', $this->currentPleb->id) + ->exists(); + }, + 'nostrLoggedOut' => function () { + $this->isAllowed = false; + $this->currentPubkey = null; + $this->currentPleb = null; + }, +]); + +$approve = function () { + Vote::query()->updateOrCreate([ + 'project_proposal_id' => $this->projectProposal->id, + 'einundzwanzig_pleb_id' => $this->currentPleb->id, + ], [ + 'value' => true, + ]); + $this->form->reset(); + $this->ownVoteExists = true; + $this->boardVotes = Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->where('value', false) + ->get(); + $this->otherVotes = Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->where('value', false) + ->get(); +}; + +$notApprove = function () { + $this->form->validate(); + + Vote::query()->updateOrCreate([ + 'project_proposal_id' => $this->projectProposal->id, + 'einundzwanzig_pleb_id' => $this->currentPleb->id, + ], [ + 'value' => false, + 'reason' => $this->form->reason, + ]); + $this->form->reset(); + $this->ownVoteExists = true; + $this->reasons = Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->where('value', false) + ->get(); +}; + +?> + + + @volt + + + + + + + + + + + + + Zurück zur Übersicht + + + + {{ $projectProposal->created_at->format('D d M, Y') }} + + + + + {{ $projectProposal->name }} + + + {!! $projectProposal->description !!} + + + + + + + + + + Eingereicht von + {{ $projectProposal->einundzwanzigPleb->profile->name }} + + + + + + + Webseite + + + {{ number_format($projectProposal->support_in_sats, 0, ',', '.') }} Sats + + + + + + + + + + + + + + Ablehnungen ({{ count($reasons) }}) + + + @foreach($reasons as $reason) + + + + + + + {{ $reason->einundzwanzigPleb->profile->name }} + + {{ $reason->reason }} + + + @endforeach + + + + + + + + + + + @if(!$ownVoteExists) + + + + Zustimmen + + + + Ablehnen + + + + @else + + Du hast bereits abgestimmt. + + @endif + + + + + + + Zustimmungen des Vorstands ({{ count($boardVotes) }}) + + + + @foreach($boardVotes as $vote) + + + + + + + + + {{ $vote->einundzwanzigPleb->profile->name }} + + + + + + @endforeach + + + + + + + + Zustimmungen der übrigen Mitglieder ({{ count($otherVotes) }}) + + + + @foreach($otherVotes as $vote) + + + + + + + + + {{ $vote->einundzwanzigPleb->profile->name }} + + + + + + @endforeach + + + + + + + + + @endvolt + diff --git a/resources/views/pages/association/project-support/index.blade.php b/resources/views/pages/association/project-support/index.blade.php index 08489a1..fac7df4 100644 --- a/resources/views/pages/association/project-support/index.blade.php +++ b/resources/views/pages/association/project-support/index.blade.php @@ -135,7 +135,7 @@ $delete = function ($id) { class="flex bg-white dark:bg-gray-800 shadow-sm rounded-xl overflow-hidden"> + href="{{ route('association.projectSupport.item', ['projectProposal' => $project]) }}"> @@ -170,10 +170,10 @@ $delete = function ($id) { Webseite - @if($project->votes->count() > 0) + @if($project->votes->where('value', true)->count() > 0) - Anzahl der Unterstützer: +{{ $project->votes->count() }} + Anzahl der Unterstützer: +{{ $project->votes->where('value', true)->count() }} @endif
Du hast bereits abgestimmt.