From 1bf8c66b3505c7f9f02a30b87281635433465926 Mon Sep 17 00:00:00 2001 From: fsociety Date: Fri, 25 Oct 2024 15:02:23 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20feat(news):=20add=20news=20manag?= =?UTF-8?q?ement=20with=20upload=20functionality=20and=20category=20select?= =?UTF-8?q?ion=20in=20the=20association=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Enums/Icon.php | 11 + app/Enums/NewsCategory.php | 46 +++ app/Livewire/Forms/NotificationForm.php | 18 ++ app/Models/Notification.php | 36 +++ ...0_25_121448_create_notifications_table.php | 30 ++ .../layouts/navigation/association.blade.php | 10 + .../pages/association/news/index.blade.php | 271 ++++++++++++++++++ 7 files changed, 422 insertions(+) create mode 100644 app/Enums/Icon.php create mode 100644 app/Enums/NewsCategory.php create mode 100644 app/Livewire/Forms/NotificationForm.php create mode 100644 app/Models/Notification.php create mode 100644 database/migrations/2024_10_25_121448_create_notifications_table.php create mode 100644 resources/views/pages/association/news/index.blade.php diff --git a/app/Enums/Icon.php b/app/Enums/Icon.php new file mode 100644 index 0000000..9faa0d0 --- /dev/null +++ b/app/Enums/Icon.php @@ -0,0 +1,11 @@ +map( + fn( + $option, + $name + ) => [ + 'value' => $option, + 'label' => __( + self::fromName($name) + ->label() + ), + 'icon' => self::fromName($name) + ->icon(), + ] + ) + ->values() + ->toArray(); + } +} diff --git a/app/Livewire/Forms/NotificationForm.php b/app/Livewire/Forms/NotificationForm.php new file mode 100644 index 0000000..56b4f85 --- /dev/null +++ b/app/Livewire/Forms/NotificationForm.php @@ -0,0 +1,18 @@ + NewsCategory::class, + ]; + } + + public function registerMediaCollections(): void + { + $this + ->addMediaCollection('pdf') + ->acceptsMimeTypes(['application/pdf']) + ->singleFile(); + } + + public function einundzwanzigPleb(): BelongsTo + { + return $this->belongsTo(EinundzwanzigPleb::class); + } +} diff --git a/database/migrations/2024_10_25_121448_create_notifications_table.php b/database/migrations/2024_10_25_121448_create_notifications_table.php new file mode 100644 index 0000000..072ba27 --- /dev/null +++ b/database/migrations/2024_10_25_121448_create_notifications_table.php @@ -0,0 +1,30 @@ +id(); + $table->foreignId('einundzwanzig_pleb_id')->constrained()->cascadeOnDelete(); + $table->string('name'); + $table->text('description')->nullable(); + $table->unsignedInteger('category'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('notifications'); + } +}; diff --git a/resources/views/components/layouts/navigation/association.blade.php b/resources/views/components/layouts/navigation/association.blade.php index 1330d5f..e0c3255 100644 --- a/resources/views/components/layouts/navigation/association.blade.php +++ b/resources/views/components/layouts/navigation/association.blade.php @@ -6,6 +6,16 @@ Verein