From 30e78711c98096cc9984e7becd2a9b3247be47c0 Mon Sep 17 00:00:00 2001 From: HolgerHatGarKeineNode Date: Sun, 18 Jan 2026 13:23:20 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20reusable=20Blade=20components?= =?UTF-8?q?=20for=20inputs=20and=20layouts:=20FilePond,=20navigation=20gro?= =?UTF-8?q?ups,=20and=20notification=20buttons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .junie/guidelines.md | 3 +- AGENTS.md | 3 +- CLAUDE.md | 3 +- composer.json | 1 + composer.lock | 96 +++- config/livewire.php | 2 +- resources/views/components/detail.blade.php | 60 +++ .../views/components/input/filepond.blade.php | 30 ++ .../views/components/input/group.blade.php | 13 + .../components/input/simple-mde.blade.php | 53 +++ .../components/layout/⚡sidebar.blade.php | 89 ++++ .../views/components/layouts/app.blade.php | 197 ++++++++ .../layouts/navigation/admin.blade.php | 30 ++ .../layouts/navigation/association.blade.php | 50 ++ .../layouts/navigation/courses.blade.php | 88 ++++ .../layouts/navigation/events.blade.php | 88 ++++ .../layouts/navigation/legacy.blade.php | 11 + .../layouts/navigation/meetups.blade.php | 26 + .../layouts/navigation/nostr.blade.php | 11 + .../partials/dark-mode-toggle.blade.php | 22 + .../partials/notification-buttons.blade.php | 64 +++ .../layouts/partials/search-button.blade.php | 201 ++++++++ .../layouts/partials/styles.blade.php | 3 + .../layouts/partials/user-button.blade.php | 49 ++ .../views/components/project-card.blade.php | 124 +++++ .../association/election/index.blade.php | 2 - .../association/election/show.blade.php | 8 - .../association/members/admin.blade.php | 6 - .../views/livewire/association/news.blade.php | 450 +++++++++++------- .../project-support/form/create.blade.php | 51 +- .../project-support/form/edit.blade.php | 186 +++++--- .../project-support/index.blade.php | 8 - .../project-support/show.blade.php | 174 ++++--- 33 files changed, 1853 insertions(+), 349 deletions(-) create mode 100644 resources/views/components/detail.blade.php create mode 100644 resources/views/components/input/filepond.blade.php create mode 100644 resources/views/components/input/group.blade.php create mode 100644 resources/views/components/input/simple-mde.blade.php create mode 100644 resources/views/components/layout/⚡sidebar.blade.php create mode 100644 resources/views/components/layouts/app.blade.php create mode 100644 resources/views/components/layouts/navigation/admin.blade.php create mode 100644 resources/views/components/layouts/navigation/association.blade.php create mode 100644 resources/views/components/layouts/navigation/courses.blade.php create mode 100644 resources/views/components/layouts/navigation/events.blade.php create mode 100644 resources/views/components/layouts/navigation/legacy.blade.php create mode 100644 resources/views/components/layouts/navigation/meetups.blade.php create mode 100644 resources/views/components/layouts/navigation/nostr.blade.php create mode 100644 resources/views/components/layouts/partials/dark-mode-toggle.blade.php create mode 100644 resources/views/components/layouts/partials/notification-buttons.blade.php create mode 100644 resources/views/components/layouts/partials/search-button.blade.php create mode 100644 resources/views/components/layouts/partials/styles.blade.php create mode 100644 resources/views/components/layouts/partials/user-button.blade.php create mode 100644 resources/views/components/project-card.blade.php diff --git a/.junie/guidelines.md b/.junie/guidelines.md index 8bf0232..1d02318 100644 --- a/.junie/guidelines.md +++ b/.junie/guidelines.md @@ -10,6 +10,7 @@ This application is a Laravel application and its main Laravel ecosystems packag - php - 8.3.29 - laravel/framework (LARAVEL) - v12 +- laravel/nightwatch (NIGHTWATCH) - v1 - laravel/prompts (PROMPTS) - v0 - laravel/reverb (REVERB) - v1 - laravel/sail (SAIL) - v1 @@ -18,7 +19,7 @@ This application is a Laravel application and its main Laravel ecosystems packag - laravel/pint (PINT) - v1 - pestphp/pest (PEST) - v3 - phpunit/phpunit (PHPUNIT) - v11 -- laravel-echo (ECHO) - v1 +- laravel-echo (ECHO) - v2 - tailwindcss (TAILWINDCSS) - v3 ## Conventions diff --git a/AGENTS.md b/AGENTS.md index 8bf0232..1d02318 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,6 +10,7 @@ This application is a Laravel application and its main Laravel ecosystems packag - php - 8.3.29 - laravel/framework (LARAVEL) - v12 +- laravel/nightwatch (NIGHTWATCH) - v1 - laravel/prompts (PROMPTS) - v0 - laravel/reverb (REVERB) - v1 - laravel/sail (SAIL) - v1 @@ -18,7 +19,7 @@ This application is a Laravel application and its main Laravel ecosystems packag - laravel/pint (PINT) - v1 - pestphp/pest (PEST) - v3 - phpunit/phpunit (PHPUNIT) - v11 -- laravel-echo (ECHO) - v1 +- laravel-echo (ECHO) - v2 - tailwindcss (TAILWINDCSS) - v3 ## Conventions diff --git a/CLAUDE.md b/CLAUDE.md index 8bf0232..1d02318 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,6 +10,7 @@ This application is a Laravel application and its main Laravel ecosystems packag - php - 8.3.29 - laravel/framework (LARAVEL) - v12 +- laravel/nightwatch (NIGHTWATCH) - v1 - laravel/prompts (PROMPTS) - v0 - laravel/reverb (REVERB) - v1 - laravel/sail (SAIL) - v1 @@ -18,7 +19,7 @@ This application is a Laravel application and its main Laravel ecosystems packag - laravel/pint (PINT) - v1 - pestphp/pest (PEST) - v3 - phpunit/phpunit (PHPUNIT) - v11 -- laravel-echo (ECHO) - v1 +- laravel-echo (ECHO) - v2 - tailwindcss (TAILWINDCSS) - v3 ## Conventions diff --git a/composer.json b/composer.json index a3e5412..fcc89f2 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "archtechx/enums": "^1.1", "calebporzio/sushi": "^2.5", "laravel/framework": "^12.0", + "laravel/nightwatch": "^1.22", "laravel/reverb": "^1.0", "laravel/sail": "^1.31", "laravel/tinker": "^2.9", diff --git a/composer.lock b/composer.lock index 5c83e22..c0a5d32 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2c65490e6b7a44170109685c7d29bf07", + "content-hash": "7ce22785474454dbae00168baafb6ccf", "packages": [ { "name": "akuechler/laravel-geoly", @@ -2041,6 +2041,100 @@ }, "time": "2026-01-13T15:29:06+00:00" }, + { + "name": "laravel/nightwatch", + "version": "v1.22.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/nightwatch.git", + "reference": "a6ef3f6bccc81e69e17e4f67992c1a3ab6a85110" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/nightwatch/zipball/a6ef3f6bccc81e69e17e4f67992c1a3ab6a85110", + "reference": "a6ef3f6bccc81e69e17e4f67992c1a3ab6a85110", + "shasum": "" + }, + "require": { + "ext-zlib": "*", + "guzzlehttp/promises": "^2.0", + "laravel/framework": "^10.0|^11.0|^12.0", + "monolog/monolog": "^3.6", + "nesbot/carbon": "^2.0|^3.0", + "php": "^8.2", + "psr/http-message": "^1.0|^2.0", + "psr/log": "^1.0|^2.0|^3.0", + "ramsey/uuid": "^4.0", + "symfony/console": "^6.0|^7.0", + "symfony/http-foundation": "^6.0|^7.0", + "symfony/polyfill-php84": "^1.29" + }, + "require-dev": { + "aws/aws-sdk-php": "^3.349", + "ext-pcntl": "*", + "ext-pdo": "*", + "guzzlehttp/guzzle": "^7.0", + "guzzlehttp/psr7": "^2.0", + "laravel/horizon": "^5.4", + "laravel/pint": "1.21.0", + "laravel/vapor-core": "^2.38.2", + "livewire/livewire": "^2.0|^3.0", + "mockery/mockery": "^1.0", + "mongodb/laravel-mongodb": "^4.0|^5.0", + "orchestra/testbench": "^8.0|^9.0|^10.0", + "orchestra/testbench-core": "^8.0|^9.0|^10.0", + "orchestra/workbench": "^8.0|^9.0|^10.0", + "phpstan/phpstan": "^1.0", + "phpunit/phpunit": "^10.0|^11.0|^12.0", + "singlestoredb/singlestoredb-laravel": "^1.0|^2.0", + "spatie/laravel-ignition": "^2.0", + "symfony/mailer": "^6.0|^7.0", + "symfony/mime": "^6.0|^7.0", + "symfony/var-dumper": "^6.0|^7.0" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "Nightwatch": "Laravel\\Nightwatch\\Facades\\Nightwatch" + }, + "providers": [ + "Laravel\\Nightwatch\\NightwatchServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "agent/helpers.php" + ], + "psr-4": { + "Laravel\\Nightwatch\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The official Laravel Nightwatch package.", + "homepage": "https://nightwatch.laravel.com", + "keywords": [ + "Insights", + "laravel", + "monitoring" + ], + "support": { + "docs": "https://nightwatch.laravel.com/docs", + "issues": "https://github.com/laravel/nightwatch/issues", + "source": "https://github.com/laravel/nightwatch" + }, + "time": "2026-01-15T04:53:20+00:00" + }, { "name": "laravel/prompts", "version": "v0.3.10", diff --git a/config/livewire.php b/config/livewire.php index 2690e9b..f24b128 100644 --- a/config/livewire.php +++ b/config/livewire.php @@ -70,7 +70,7 @@ return [ 'make_command' => [ 'type' => 'sfc', // Options: 'sfc', 'mfc', 'class' - 'emoji' => true, // Options: true, false + 'emoji' => false, // Options: true, false 'with' => [ 'js' => false, 'css' => false, diff --git a/resources/views/components/detail.blade.php b/resources/views/components/detail.blade.php new file mode 100644 index 0000000..dde6da2 --- /dev/null +++ b/resources/views/components/detail.blade.php @@ -0,0 +1,60 @@ +
+ + @if($row->application_text ) +
+
+
+ + + +
{{ $row->application_text }}
+
+
+
+ @endif + +
+

+ bisherige Zahlungen

+ + + + + + + + + + + + + @foreach($row->paymentEvents as $payment) + + + + + + @endforeach + +
+
Satoshis
+
+
{{ $payment->amount }}
+
+
{{ $payment->year }}
+
+
{{ $payment->event_id }}
+
+
+ +
diff --git a/resources/views/components/input/filepond.blade.php b/resources/views/components/input/filepond.blade.php new file mode 100644 index 0000000..39e3bbb --- /dev/null +++ b/resources/views/components/input/filepond.blade.php @@ -0,0 +1,30 @@ +
in Ordner suchen ' }}', + allowMultiple: {{ isset($attributes['multiple']) ? 'true' : 'false' }}, + server: { + process: (fieldName, file, metadata, load, error, progress, abort, transfer, options) => { + @this.upload('{{ $attributes['wire:model'] }}', file, load, error, progress) + }, + revert: (filename, load) => { + @this.removeUpload('{{ $attributes['wire:model'] }}', filename, load) + }, + load: (source, load, error, progress, abort, headers) => { + @this.load('{{ $attributes['wire:model'] }}', load, error, progress, abort, headers) + }, + }, + }); + FilePond.create($refs.input); + " +> + +
diff --git a/resources/views/components/input/group.blade.php b/resources/views/components/input/group.blade.php new file mode 100644 index 0000000..fd9d40e --- /dev/null +++ b/resources/views/components/input/group.blade.php @@ -0,0 +1,13 @@ +@props([ + 'for', + 'label', +]) +
+ +
+ {{ $slot }} +
+
diff --git a/resources/views/components/input/simple-mde.blade.php b/resources/views/components/input/simple-mde.blade.php new file mode 100644 index 0000000..7af96d5 --- /dev/null +++ b/resources/views/components/input/simple-mde.blade.php @@ -0,0 +1,53 @@ +
+
+ +
+ +
diff --git a/resources/views/components/layout/⚡sidebar.blade.php b/resources/views/components/layout/⚡sidebar.blade.php new file mode 100644 index 0000000..3225c49 --- /dev/null +++ b/resources/views/components/layout/⚡sidebar.blade.php @@ -0,0 +1,89 @@ +route()->getName(); + $this->currentRoute = $currentLivewireRouteName; + } +}; +?> + +
+ @php + $isCurrentRouteClass = 'pl-4 pr-3 py-2 rounded-lg mb-0.5 last:mb-0 bg-[linear-gradient(135deg,var(--tw-gradient-stops))] from-orange-500/[0.12] dark:from-orange-500/[0.24] to-orange-500/[0.04]'; + $isNotCurrentRouteClass = 'pl-4 pr-3 py-2 rounded-lg mb-0.5 last:mb-0'; + $isCurrentSubItem = 'block text-orange-500 transition truncate'; + $isNotCurrentSubItem = 'block text-gray-500/90 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition truncate'; + @endphp + + + + + + +
diff --git a/resources/views/components/layouts/app.blade.php b/resources/views/components/layouts/app.blade.php new file mode 100644 index 0000000..f884b3d --- /dev/null +++ b/resources/views/components/layouts/app.blade.php @@ -0,0 +1,197 @@ + + + + + + {!! seo($seo ?? null) !!} + + {{ $title ?? 'Page Title' }} + @livewireStyles + @wireUiScripts + @stack('scripts') + @vite(['resources/js/app.js','resources/css/app.css']) + @googlefonts + + + + @include('components.layouts.partials.styles') + + + + + +
+ +
+ +
+
+
+ + +
+ + + +
+ + +
+ + {{--@include('components.layouts.partials.search-button')--}} + + {{--@include('components.layouts.partials.notification-buttons')--}} + + + @if(\App\Support\NostrAuth::check()) +
+ @csrf + + + @else + + @endif + + +
+ + +
+ + {{--@include('components.layouts.partials.dark-mode-toggle')--}} + + + {{--
--}} + + {{--@include('components.layouts.partials.user-button')--}} + +
+ +
+
+
+
+ {{ $slot }} +
+
+
+@livewireScriptConfig + + + + diff --git a/resources/views/components/layouts/navigation/admin.blade.php b/resources/views/components/layouts/navigation/admin.blade.php new file mode 100644 index 0000000..4dc4fed --- /dev/null +++ b/resources/views/components/layouts/navigation/admin.blade.php @@ -0,0 +1,30 @@ + +
+

+ + Admin-Bereich +

+ +
diff --git a/resources/views/components/layouts/navigation/association.blade.php b/resources/views/components/layouts/navigation/association.blade.php new file mode 100644 index 0000000..999dfd0 --- /dev/null +++ b/resources/views/components/layouts/navigation/association.blade.php @@ -0,0 +1,50 @@ + +
+

+ + Verein +

+ +
diff --git a/resources/views/components/layouts/navigation/courses.blade.php b/resources/views/components/layouts/navigation/courses.blade.php new file mode 100644 index 0000000..c69241a --- /dev/null +++ b/resources/views/components/layouts/navigation/courses.blade.php @@ -0,0 +1,88 @@ + +
+

+ + Courses +

+ +
diff --git a/resources/views/components/layouts/navigation/events.blade.php b/resources/views/components/layouts/navigation/events.blade.php new file mode 100644 index 0000000..11af2a9 --- /dev/null +++ b/resources/views/components/layouts/navigation/events.blade.php @@ -0,0 +1,88 @@ + +
+

+ + Events +

+ +
diff --git a/resources/views/components/layouts/navigation/legacy.blade.php b/resources/views/components/layouts/navigation/legacy.blade.php new file mode 100644 index 0000000..599ca18 --- /dev/null +++ b/resources/views/components/layouts/navigation/legacy.blade.php @@ -0,0 +1,11 @@ + +
+

+ + Legacy +

+
    + +
+
diff --git a/resources/views/components/layouts/navigation/meetups.blade.php b/resources/views/components/layouts/navigation/meetups.blade.php new file mode 100644 index 0000000..afaabcc --- /dev/null +++ b/resources/views/components/layouts/navigation/meetups.blade.php @@ -0,0 +1,26 @@ + +
+

+ + Meetups +

+ +
diff --git a/resources/views/components/layouts/navigation/nostr.blade.php b/resources/views/components/layouts/navigation/nostr.blade.php new file mode 100644 index 0000000..c940e5d --- /dev/null +++ b/resources/views/components/layouts/navigation/nostr.blade.php @@ -0,0 +1,11 @@ + +
+

+ + Nostr +

+
    + +
+
diff --git a/resources/views/components/layouts/partials/dark-mode-toggle.blade.php b/resources/views/components/layouts/partials/dark-mode-toggle.blade.php new file mode 100644 index 0000000..7b58c67 --- /dev/null +++ b/resources/views/components/layouts/partials/dark-mode-toggle.blade.php @@ -0,0 +1,22 @@ +
+ + +
diff --git a/resources/views/components/layouts/partials/notification-buttons.blade.php b/resources/views/components/layouts/partials/notification-buttons.blade.php new file mode 100644 index 0000000..917453d --- /dev/null +++ b/resources/views/components/layouts/partials/notification-buttons.blade.php @@ -0,0 +1,64 @@ + diff --git a/resources/views/components/layouts/partials/search-button.blade.php b/resources/views/components/layouts/partials/search-button.blade.php new file mode 100644 index 0000000..e9b69de --- /dev/null +++ b/resources/views/components/layouts/partials/search-button.blade.php @@ -0,0 +1,201 @@ + +
+ + + + + + +
diff --git a/resources/views/components/layouts/partials/styles.blade.php b/resources/views/components/layouts/partials/styles.blade.php new file mode 100644 index 0000000..c9c2354 --- /dev/null +++ b/resources/views/components/layouts/partials/styles.blade.php @@ -0,0 +1,3 @@ + diff --git a/resources/views/components/layouts/partials/user-button.blade.php b/resources/views/components/layouts/partials/user-button.blade.php new file mode 100644 index 0000000..338c0d7 --- /dev/null +++ b/resources/views/components/layouts/partials/user-button.blade.php @@ -0,0 +1,49 @@ +
+ +
+
+
Acme Inc.
+
Administrator
+
+ +
+
diff --git a/resources/views/components/project-card.blade.php b/resources/views/components/project-card.blade.php new file mode 100644 index 0000000..a8d6c5c --- /dev/null +++ b/resources/views/components/project-card.blade.php @@ -0,0 +1,124 @@ +@props(['project', 'currentPleb', 'section' => 'all']) + +@php + $boardVotes = $project->votes->filter(function ($vote) { + return in_array($vote->einundzwanzigPleb->npub, config('einundzwanzig.config.current_board')); + }); + $approveCount = $boardVotes->where('value', 1)->count(); + $disapproveCount = $boardVotes->where('value', 0)->count(); + + $shouldDisplay = match($section) { + 'all' => true, + 'new' => $approveCount < 3, + 'supported' => $project->sats_paid > 0, + 'rejected' => $disapproveCount >= 3, + 'approved' => ($approveCount === 3 || $disapproveCount !== 3), + default => true, + }; +@endphp + +@if($shouldDisplay) + +
+ + @if(!$project->sats_paid) + + Meetup 01 + + + @else +
+ Meetup 01 + +
+ @endif + +
+
+
+ Eingereicht von: {{ $project->einundzwanzigPleb->profile?->name ?? str($project->einundzwanzigPleb->npub)->limit(32) }} +
+
+

+ {{ $project->name }} +

+
+
+ {!! strip_tags($project->description) !!} +
+
+ +
+ +
+ {{ number_format($project->support_in_sats, 0, ',', '.') }} Sats +
+
+ Webseite +
+ + @if($project->votes->where('value', true)->count() > 0) + + @endif +
+
+ @if( + ($currentPleb && $currentPleb->id === $project->einundzwanzig_pleb_id) + || ($currentPleb && in_array($currentPleb->npub, config('einundzwanzig.config.current_board'), true)) + ) + + + @endif + @if(($currentPleb && $currentPleb->association_status->value > 2) || $project->accepted) + + @endif +
+
+ @if($project->sats_paid) +
+ Wurde mit {{ number_format($project->sats_paid, 0, ',', '.') }} Sats + unterstützt +
+ @endif +
+
+
+@endif diff --git a/resources/views/livewire/association/election/index.blade.php b/resources/views/livewire/association/election/index.blade.php index feac298..28fdbc3 100644 --- a/resources/views/livewire/association/election/index.blade.php +++ b/resources/views/livewire/association/election/index.blade.php @@ -6,8 +6,6 @@ use App\Support\NostrAuth; use Livewire\Component; new class extends Component { - public $layout = 'layouts.app'; - public $title = __('Wahlen'); public bool $isAllowed = false; diff --git a/resources/views/livewire/association/election/show.blade.php b/resources/views/livewire/association/election/show.blade.php index e32dfa1..0aa72be 100644 --- a/resources/views/livewire/association/election/show.blade.php +++ b/resources/views/livewire/association/election/show.blade.php @@ -320,14 +320,6 @@ new class extends Component { \App\Support\Broadcast::on('votes')->as('newVote')->sendNow(); } - public function render() - { - return view('livewire.association.election.show') - ->layout('layouts.app') - ->with([ - 'seo' => new \RalphJSmit\Laravel\SEO\Support\SEOData(title: 'Wahlen ' . $this->election->year, description: 'Wahlen des Vereins im Jahr ' . $this->election->year) - ]); - } }; ?> diff --git a/resources/views/livewire/association/members/admin.blade.php b/resources/views/livewire/association/members/admin.blade.php index 5df7a79..9b0e030 100644 --- a/resources/views/livewire/association/members/admin.blade.php +++ b/resources/views/livewire/association/members/admin.blade.php @@ -61,12 +61,6 @@ new class extends Component { } } - public function render() - { - return view('livewire.association.members.admin') - ->layout('layouts.app') - ->title(__('Mitglieder')); - } }; ?> diff --git a/resources/views/livewire/association/news.blade.php b/resources/views/livewire/association/news.blade.php index 713ef04..c36ef16 100644 --- a/resources/views/livewire/association/news.blade.php +++ b/resources/views/livewire/association/news.blade.php @@ -1,207 +1,303 @@ - -
- @if($isAllowed) -
+ +use App\Enums\NewsCategory; +use App\Models\Notification; +use App\Support\NostrAuth; +use Illuminate\Support\Collection; +use Livewire\Component; +use Livewire\Attributes\Layout; +use Livewire\Attributes\Title; +use Livewire\WithFileUploads; - -
+new +#[Layout('layouts.app')] +#[Title('News')] +class extends Component { + use WithFileUploads; - -
-
-
+ public Collection|array $news = []; -
+ public array $form = [ + 'category' => '', + 'name' => '', + 'description' => '', + ]; - -
-

- News

-
+ public mixed $file; -
+ public bool $isAllowed = false; - -
- -
-
- Menu -
-
    - @foreach(\App\Enums\NewsCategory::selectOptions() as $category) -
  • -
    - - {{ $category['label'] }} -
    -
  • - @endforeach -
+ public bool $canEdit = false; + + public function mount(): void + { + if (NostrAuth::check()) { + $currentPubkey = NostrAuth::pubkey(); + $currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $currentPubkey)->first(); + + if ($currentPleb && $currentPleb->association_status->value > 1 && $currentPleb->paymentEvents()->where('year', + date('Y'))->where('paid', true)->exists()) { + $this->isAllowed = true; + } + + if ($currentPleb && $currentPleb->association_status->value > 2) { + $this->canEdit = true; + } + + $this->news = \App\Models\Notification::query() + ->with(['einundzwanzigPleb.profile']) + ->latest() + ->get(); + } + } + + public function save(): void + { + $this->validate([ + 'file' => 'required|file|mimes:pdf', + 'form.category' => 'required|string|in:'.implode(',', NewsCategory::values()), + 'form.name' => 'required|string|max:255', + 'form.description' => 'nullable|string', + ]); + + $currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', NostrAuth::pubkey())->first(); + + $news = Notification::query()->create([ + 'name' => $this->form['name'], + 'description' => $this->form['description'] ?? null, + 'category' => $this->form['category'], + 'einundzwanzig_pleb_id' => $currentPleb->id, + ]); + + if ($this->file) { + $news + ->addMedia($this->file) + ->toMediaCollection('pdf'); + } + + $this->reset(['form', 'file']); + + $this->news = \App\Models\Notification::query() + ->with(['einundzwanzigPleb.profile']) + ->latest() + ->get(); + } + + public function delete(int $id): void + { + $news = Notification::query()->find($id); + if ($news) { + $news->delete(); + } + + $this->news = \App\Models\Notification::query() + ->with(['einundzwanzigPleb.profile']) + ->latest() + ->get(); + } +}; +?> + +
+ @if($isAllowed) +
+ +
+ + +
+ + +
+
+
+ +
+ + +
+

+ News

+
+ +
+ + +
+ +
+
+ Menu
+
    + @foreach(\App\Enums\NewsCategory::selectOptions() as $category) +
  • +
    + + {{ $category['label'] }} +
    +
  • + @endforeach +
+
- -
-
+ +
+
-
- @forelse($news as $post) -
-
- -
- {{ $post->einundzwanzigPleb->profile?->name }} -
- -
- -

- {{ $post->name }} -

-

- {{ $post->description }} -

- -
+
+ @forelse($news as $post) +
+
+ +
+ {{ $post->einundzwanzigPleb->profile?->name }} +
+ +
+ +

+ {{ $post->name }} +

+

+ {{ $post->description }} +

+ +
+
-
-
- - - - {{ $post->einundzwanzigPleb->profile->name }} -
+ class="font-medium text-amber-500 hover:text-amber-600 dark:hover:text-amber-400"> +
+ + + + {{ $post->einundzwanzigPleb->profile->name }}
-
+
+
{{ $post->created_at->format('d.m.Y') }} -
-
-
-
-
- - @if($canEdit) - - @endif -
-
- @empty -
-

Keine News vorhanden.

-
- @endforelse -
- -
-
- -
- - -
-
-
- - -
- - @if($canEdit) -
-
- News anlegen -
-
-
- - @error('file') - {{ $message }} - @enderror -
-
- -
-
- -
-
- -
- +
+
- @endif - -
+
+ + @if($canEdit) + + @endif +
+ + @empty +
+

Keine News vorhanden.

+
+ @endforelse
+
-
- @else -
-
-
-

- News -

-

- Du bist nicht berechtigt, die News einzusehen. -

+ +
+
+
+ + +
+ + @if($canEdit) +
+
+ News anlegen +
+
+
+ + @error('file') + {{ $message }} + @enderror +
+
+ +
+
+ +
+
+ +
+ +
+
+ @endif + +
+
+
- @endif -
- + +
+ @else +
+
+
+

+ News +

+

+ Du bist nicht berechtigt, die News einzusehen. +

+
+
+
+ @endif +
diff --git a/resources/views/livewire/association/project-support/form/create.blade.php b/resources/views/livewire/association/project-support/form/create.blade.php index 73ae201..9060af8 100644 --- a/resources/views/livewire/association/project-support/form/create.blade.php +++ b/resources/views/livewire/association/project-support/form/create.blade.php @@ -1,4 +1,53 @@ - + '', + 'description' => '', + ]; + + public bool $isAllowed = false; + + public function mount(): void + { + if (NostrAuth::check()) { + $currentPubkey = NostrAuth::pubkey(); + $currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $currentPubkey)->first(); + + if ($currentPleb && $currentPleb->association_status->value > 1 && $currentPleb->paymentEvents()->where('year', date('Y'))->where('paid', true)->exists()) { + $this->isAllowed = true; + } + } + } + + public function save(): void + { + $this->validate([ + 'form.name' => 'required|string|max:255', + 'form.description' => 'required|string', + ]); + + ProjectProposal::query()->create([ + 'name' => $this->form['name'], + 'description' => $this->form['description'], + 'einundzwanzig_pleb_id' => \App\Models\EinundzwanzigPleb::query()->where('pubkey', NostrAuth::pubkey())->first()->id, + ]); + + $this->redirectRoute('association.projectSupport'); + } +}; +?> + +
@if($isAllowed)
diff --git a/resources/views/livewire/association/project-support/form/edit.blade.php b/resources/views/livewire/association/project-support/form/edit.blade.php index f7770cb..a946dd2 100644 --- a/resources/views/livewire/association/project-support/form/edit.blade.php +++ b/resources/views/livewire/association/project-support/form/edit.blade.php @@ -1,74 +1,128 @@ - -
- @if($isAllowed) -
-
-
-

- Projektförderung bearbeiten -

-
-
+ - -
-
-

- Formular -

-
-
- - @error('form.name') - {{ $message }} - @enderror -
-
- - @error('form.description') - {{ $message }} - @enderror -
- -
-
-
+use App\Models\ProjectProposal; +use App\Support\NostrAuth; +use Livewire\Attributes\Layout; +use Livewire\Attributes\Title; +use Livewire\Component; - -
-
-

- Information -

-

- Bearbeite die Projektförderung und speichere deine Änderungen. -

-
-
+new +#[Layout('layouts.app')] +#[Title('Projektförderung bearbeiten')] +class extends Component { + public ProjectProposal $project; + + public array $form = [ + 'name' => '', + 'description' => '', + ]; + + public bool $isAllowed = false; + + public function mount(ProjectProposal $project): void + { + $this->project = $project; + + if (NostrAuth::check()) { + $currentPubkey = NostrAuth::pubkey(); + $currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $currentPubkey)->first(); + + if ($currentPleb && $currentPleb->id === $project->einundzwanzig_pleb_id) { + $this->isAllowed = true; + $this->form = [ + 'name' => $project->name, + 'description' => $project->description, + ]; + } + } + } + + public function update(): void + { + $this->validate([ + 'form.name' => 'required|string|max:255', + 'form.description' => 'required|string', + ]); + + $this->project->update([ + 'name' => $this->form['name'], + 'description' => $this->form['description'], + ]); + + $this->redirectRoute('association.projectSupport.item', $this->project); + } +}; +?> + +
+ @if($isAllowed) +
+
+
+

+ Projektförderung bearbeiten +

- @else -
-
-
-

- Projektförderung -

-

- Du bist nicht berechtigt, die Projektförderung zu bearbeiten. + +

+ +
+
+

+ Formular +

+
+
+ + @error('form.name') + {{ $message }} + @enderror +
+
+ + @error('form.description') + {{ $message }} + @enderror +
+ +
+
+
+ + +
+
+

+ Information +

+

+ Bearbeite die Projektförderung und speichere deine Änderungen.

- @endif -
- +
+ @else +
+
+
+

+ Projektförderung +

+

+ Du bist nicht berechtigt, die Projektförderung zu bearbeiten. +

+
+
+
+ @endif +
diff --git a/resources/views/livewire/association/project-support/index.blade.php b/resources/views/livewire/association/project-support/index.blade.php index da296cf..d5f1bb3 100644 --- a/resources/views/livewire/association/project-support/index.blade.php +++ b/resources/views/livewire/association/project-support/index.blade.php @@ -97,14 +97,6 @@ new class extends Component { $this->loadProjects(); } - public function render() - { - return view('livewire.association.project-support') - ->layout('layouts.app') - ->with([ - 'seo' => new \RalphJSmit\Laravel\SEO\Support\SEOData(title: 'Projekt Unterstützungen', description: 'Einundzwanzig Projektunterstützungen') - ]); - } }; ?> diff --git a/resources/views/livewire/association/project-support/show.blade.php b/resources/views/livewire/association/project-support/show.blade.php index 7f6e13c..61b831f 100644 --- a/resources/views/livewire/association/project-support/show.blade.php +++ b/resources/views/livewire/association/project-support/show.blade.php @@ -1,85 +1,107 @@ - -
- @if($isAllowed) -
-
-
-

- {{ $project->name }} -

-
- @if($project->status === 'pending') - - @elseif($project->status === 'active') - - @else - - @endif -
-
-
+ - -
-
-

- Details -

-
-
-
Status
-
- @if($project->status === 'pending') - Ausstehend - @elseif($project->status === 'active') - Aktiv - @else - Archiviert - @endif -
-
-
-
Erstellt am
-
- {{ $project->created_at->format('d.m.Y') }} -
-
-
-
-
+use App\Models\ProjectProposal; +use App\Support\NostrAuth; +use Livewire\Component; +use Livewire\Attributes\Layout; +use Livewire\Attributes\Title; - -
-
-

- Beschreibung -

-

- {{ $project->description ?? 'Keine Beschreibung' }} -

-
+new +#[Layout('layouts.app')] +#[Title('Projektförderung ')] +class extends Component { + public ProjectProposal $project; + + public bool $isAllowed = false; + + public function mount(ProjectProposal $project): void + { + $this->project = $project; + if (NostrAuth::check()) { + $this->isAllowed = true; + } + } +}; +?> + +
+ @if($isAllowed) +
+
+
+

+ {{ $project->name }} +

+
+ @if($project->status === 'pending') + + @elseif($project->status === 'active') + + @else + + @endif
- @else -
-
-
-

- Projektförderung -

-

- Du bist nicht berechtigt, die Projektförderung einzusehen. + +

+ +
+
+

+ Details +

+
+
+
Status
+
+ @if($project->status === 'pending') + Ausstehend + @elseif($project->status === 'active') + Aktiv + @else + Archiviert + @endif +
+
+
+
Erstellt am
+
+ {{ $project->created_at->format('d.m.Y') }} +
+
+
+
+
+ + +
+
+

+ Beschreibung +

+

+ {{ $project->description ?? 'Keine Beschreibung' }}

- @endif -
- +
+ @else +
+
+
+

+ Projektförderung +

+

+ Du bist nicht berechtigt, die Projektförderung einzusehen. +

+
+
+
+ @endif +