null]); state(['votes' => null]); state(['events' => null]); state(['election' => fn() => $election]); state(['signThisEvent' => '']); state([ 'plebs' => fn() => \App\Models\EinundzwanzigPleb::query() ->with([ 'profile', ]) ->whereIn('association_status', [3, 4]) ->orderBy('association_status', 'desc') ->get() ->toArray(), ]); state([ 'electionConfig' => function () { return collect(json_decode($this->election->candidates, true, 512, JSON_THROW_ON_ERROR)) ->map(function ($c) { $candidates = \App\Models\Profile::query() ->whereIn('pubkey', $c['c']) ->get() ->map(fn($p) => [ 'pubkey' => $p->pubkey, 'name' => $p->name, 'picture' => $p->picture, ]); return [ 'type' => $c['type'], 'c' => $c['c'], 'candidates' => $candidates, ]; }); }, ]); mount(function () { $this->loadEvents(); $this->loadVotes(); }); on([ 'nostrLoggedIn' => function ($pubkey) { $this->currentPubkey = $pubkey; }, ]); on([ 'echo:votes,.newVote' => function () { $this->loadEvents(); $this->loadVotes(); }, ]); $loadVotes = function () { $votes = collect($this->events) ->map(function ($event) { $votedFor = \App\Models\Profile::query() ->where('pubkey', str($event['content'])->before(',')->toString()) ->first() ->toArray(); return [ 'created_at' => $event['created_at'], 'pubkey' => $event['pubkey'], 'forpubkey' => $votedFor['pubkey'], 'type' => str($event['content'])->after(',')->toString(), ]; }) ->sortByDesc('created_at') ->unique(fn($event) => $event['pubkey'] . $event['type']) ->values() ->toArray(); $this->votes = collect($votes) ->groupBy('type') ->map(fn($votes) => [ 'type' => $votes[0]['type'], 'votes' => collect($votes) ->groupBy('forpubkey') ->map(fn($group) => ['count' => $group->count()]) ->toArray(), ]) ->values() ->toArray(); }; $loadEvents = function () { $subscription = new Subscription(); $subscriptionId = $subscription->setId(); $filter1 = new Filter(); $filter1->setKinds([2121]); // You can add multiple kind numbers $filters = [$filter1]; // You can add multiple filters. $requestMessage = new RequestMessage($subscriptionId, $filters); $relays = [ new Relay(config('services.relay')), ]; $relaySet = new RelaySet(); $relaySet->setRelays($relays); $request = new Request($relaySet, $requestMessage); $response = $request->send(); // Check for errors in the response if (isset($response[config('services.relay')][0][0]) && $response[config('services.relay')][0][0] === 'ERROR') { abort(500, 'Kann keine Events laden. Nostr Relay antwortet nicht.'); } $this->events = collect($response[config('services.relay')]) ->map(fn($event) => [ 'id' => $event->event->id, 'kind' => $event->event->kind, 'content' => $event->event->content, 'pubkey' => $event->event->pubkey, 'tags' => $event->event->tags, 'created_at' => $event->event->created_at, ]) ->toArray(); }; ?> @volt @php $positions = [ 'presidency' => ['icon' => 'fa-crown', 'title' => 'Präsidium'], 'vice_president' => ['icon' => 'fa-user-group-crown', 'title' => 'Vizepräsidium'], 'finances' => ['icon' => 'fa-bitcoin-sign', 'title' => 'Finanzen'], 'secretary' => ['icon' => 'fa-stapler', 'title' => 'Sekretär (Akurat)'], 'press_officer' => ['icon' => 'fa-newspaper', 'title' => 'Pressewart'], 'it_manager' => ['icon' => 'fa-server', 'title' => 'Technikwart'], ]; @endphp

Wahl des Vorstands {{ $election->year }}

@foreach($positions as $key => $position)

{{ $position['title'] }}

@endforeach
@endvolt