mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-01-25 04:13:17 +00:00
✨ Add reusable Blade components for inputs and layouts: FilePond, navigation groups, and notification buttons
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
]);
|
||||
}
|
||||
};
|
||||
?>
|
||||
|
||||
|
||||
@@ -61,12 +61,6 @@ new class extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.association.members.admin')
|
||||
->layout('layouts.app')
|
||||
->title(__('Mitglieder'));
|
||||
}
|
||||
};
|
||||
?>
|
||||
|
||||
|
||||
@@ -1,207 +1,303 @@
|
||||
<x-layouts.app
|
||||
:seo="new \RalphJSmit\Laravel\SEO\Support\SEOData(title: 'News', description: 'Die News des Vereins.')"
|
||||
>
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 md:py-0 w-full max-w-9xl mx-auto">
|
||||
<?php
|
||||
|
||||
<div class="xl:flex">
|
||||
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;
|
||||
|
||||
<!-- Left + Middle content -->
|
||||
<div class="md:flex flex-1">
|
||||
new
|
||||
#[Layout('layouts.app')]
|
||||
#[Title('News')]
|
||||
class extends Component {
|
||||
use WithFileUploads;
|
||||
|
||||
<!-- Left content -->
|
||||
<div class="w-full md:w-60 mb-8 md:mb-0">
|
||||
<div
|
||||
class="md:sticky md:top-16 md:h-[calc(100dvh-64px)] md:overflow-x-hidden md:overflow-y-auto no-scrollbar">
|
||||
<div class="md:py-8">
|
||||
public Collection|array $news = [];
|
||||
|
||||
<div class="flex justify-between items-center md:block">
|
||||
public array $form = [
|
||||
'category' => '',
|
||||
'name' => '',
|
||||
'description' => '',
|
||||
];
|
||||
|
||||
<!-- Title -->
|
||||
<header class="mb-6">
|
||||
<h1 class="text-2xl md:text-3xl text-gray-800 dark:text-gray-100 font-bold">
|
||||
News</h1>
|
||||
</header>
|
||||
public mixed $file;
|
||||
|
||||
</div>
|
||||
public bool $isAllowed = false;
|
||||
|
||||
<!-- Links -->
|
||||
<div
|
||||
class="flex flex-nowrap overflow-x-scroll no-scrollbar md:block md:overflow-auto px-4 md:space-y-3 -mx-4">
|
||||
<!-- Group 1 -->
|
||||
<div>
|
||||
<div
|
||||
class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase mb-3 md:sr-only">
|
||||
Menu
|
||||
</div>
|
||||
<ul class="flex flex-nowrap md:block mr-3 md:mr-0">
|
||||
@foreach(\App\Enums\NewsCategory::selectOptions() as $category)
|
||||
<li class="mr-0.5 md:mr-0 md:mb-0.5"
|
||||
wire:key="category_{{ $category['value'] }}">
|
||||
<div
|
||||
class="flex items-center px-2.5 py-2 rounded-lg whitespace-nowrap bg-white dark:bg-gray-800">
|
||||
<i class="fa-sharp-duotone fa-solid fa-{{ $category['icon'] }} shrink-0 fill-current text-amber-500 mr-2"></i>
|
||||
<span
|
||||
class="text-sm font-medium text-amber-500">{{ $category['label'] }}</span>
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
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();
|
||||
}
|
||||
};
|
||||
?>
|
||||
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 md:py-0 w-full max-w-9xl mx-auto">
|
||||
|
||||
<div class="xl:flex">
|
||||
|
||||
<!-- Left + Middle content -->
|
||||
<div class="md:flex flex-1">
|
||||
|
||||
<!-- Left content -->
|
||||
<div class="w-full md:w-60 mb-8 md:mb-0">
|
||||
<div
|
||||
class="md:sticky md:top-16 md:h-[calc(100dvh-64px)] md:overflow-x-hidden md:overflow-y-auto no-scrollbar">
|
||||
<div class="md:py-8">
|
||||
|
||||
<div class="flex justify-between items-center md:block">
|
||||
|
||||
<!-- Title -->
|
||||
<header class="mb-6">
|
||||
<h1 class="text-2xl md:text-3xl text-gray-800 dark:text-gray-100 font-bold">
|
||||
News</h1>
|
||||
</header>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Links -->
|
||||
<div
|
||||
class="flex flex-nowrap overflow-x-scroll no-scrollbar md:block md:overflow-auto px-4 md:space-y-3 -mx-4">
|
||||
<!-- Group 1 -->
|
||||
<div>
|
||||
<div
|
||||
class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase mb-3 md:sr-only">
|
||||
Menu
|
||||
</div>
|
||||
<ul class="flex flex-nowrap md:block mr-3 md:mr-0">
|
||||
@foreach(\App\Enums\NewsCategory::selectOptions() as $category)
|
||||
<li class="mr-0.5 md:mr-0 md:mb-0.5"
|
||||
wire:key="category_{{ $category['value'] }}">
|
||||
<div
|
||||
class="flex items-center px-2.5 py-2 rounded-lg whitespace-nowrap bg-white dark:bg-gray-800">
|
||||
<i class="fa-sharp-duotone fa-solid fa-{{ $category['icon'] }} shrink-0 fill-current text-amber-500 mr-2"></i>
|
||||
<span
|
||||
class="text-sm font-medium text-amber-500">{{ $category['label'] }}</span>
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Middle content -->
|
||||
<div class="flex-1 md:ml-8 xl:mx-4 2xl:mx-8">
|
||||
<div class="md:py-8">
|
||||
<!-- Middle content -->
|
||||
<div class="flex-1 md:ml-8 xl:mx-4 2xl:mx-8">
|
||||
<div class="md:py-8">
|
||||
|
||||
<div class="space-y-2">
|
||||
@forelse($news as $post)
|
||||
<article wire:key="post_{{ $post->id }}"
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<div class="flex flex-start space-x-4">
|
||||
<!-- Avatar -->
|
||||
<div class="shrink-0 mt-1.5">
|
||||
<img class="w-8 h-8 rounded-full"
|
||||
src="{{ $post->einundzwanzigPleb->profile?->picture ?? asset('einundzwanzig-alpha.jpg') }}"
|
||||
width="32" height="32"
|
||||
alt="{{ $post->einundzwanzigPleb->profile?->name }}">
|
||||
</div>
|
||||
<!-- Content -->
|
||||
<div class="grow">
|
||||
<!-- Title -->
|
||||
<h2 class="font-semibold text-gray-800 dark:text-gray-100 mb-2">
|
||||
{{ $post->name }}
|
||||
</h2>
|
||||
<p class="mb-6">
|
||||
{{ $post->description }}
|
||||
</p>
|
||||
<!-- Footer -->
|
||||
<footer class="flex flex-wrap text-sm">
|
||||
<div class="space-y-2">
|
||||
@forelse($news as $post)
|
||||
<article wire:key="post_{{ $post->id }}"
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<div class="flex flex-start space-x-4">
|
||||
<!-- Avatar -->
|
||||
<div class="shrink-0 mt-1.5">
|
||||
<img class="w-8 h-8 rounded-full"
|
||||
src="{{ $post->einundzwanzigPleb->profile?->picture ?? asset('einundzwanzig-alpha.jpg') }}"
|
||||
width="32" height="32"
|
||||
alt="{{ $post->einundzwanzigPleb->profile?->name }}">
|
||||
</div>
|
||||
<!-- Content -->
|
||||
<div class="grow">
|
||||
<!-- Title -->
|
||||
<h2 class="font-semibold text-gray-800 dark:text-gray-100 mb-2">
|
||||
{{ $post->name }}
|
||||
</h2>
|
||||
<p class="mb-6">
|
||||
{{ $post->description }}
|
||||
</p>
|
||||
<!-- Footer -->
|
||||
<footer class="flex flex-wrap text-sm">
|
||||
<div
|
||||
class="flex items-center after:block after:content-['·'] last:after:content-[''] after:text-sm after:text-gray-400 dark:after:text-gray-600 after:px-2">
|
||||
<div
|
||||
class="flex items-center after:block after:content-['·'] last:after:content-[''] after:text-sm after:text-gray-400 dark:after:text-gray-600 after:px-2">
|
||||
<div
|
||||
class="font-medium text-amber-500 hover:text-amber-600 dark:hover:text-amber-400">
|
||||
<div class="flex items-center">
|
||||
<svg class="mr-2 fill-current" width="16"
|
||||
height="16"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M15.686 5.708 10.291.313c-.4-.4-.999-.4-1.399 0s-.4 1 0 1.399l.6.6-6.794 3.696-1-1C1.299 4.61.7 4.61.3 5.009c-.4.4-.4 1 0 1.4l1.498 1.498 2.398 2.398L.6 14.001 2 15.4l3.696-3.697L9.692 15.7c.5.5 1.199.2 1.398 0 .4-.4.4-1 0-1.4l-.999-.998 3.697-6.695.6.6c.599.6 1.199.2 1.398 0 .3-.4.3-1.1-.1-1.499Zm-7.193 6.095L4.196 7.507l6.695-3.697 1.298 1.299-3.696 6.694Z"></path>
|
||||
</svg>
|
||||
{{ $post->einundzwanzigPleb->profile->name }}
|
||||
</div>
|
||||
class="font-medium text-amber-500 hover:text-amber-600 dark:hover:text-amber-400">
|
||||
<div class="flex items-center">
|
||||
<svg class="mr-2 fill-current" width="16"
|
||||
height="16"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M15.686 5.708 10.291.313c-.4-.4-.999-.4-1.399 0s-.4 1 0 1.399l.6.6-6.794 3.696-1-1C1.299 4.61.7 4.61.3 5.009c-.4.4-.4 1 0 1.4l1.498 1.498 2.398 2.398L.6 14.001 2 15.4l3.696-3.697L9.692 15.7c.5.5 1.199.2 1.398 0 .4-.4.4-1 0-1.4l-.999-.998 3.697-6.695.6.6c.599.6 1.199.2 1.398 0 .3-.4.3-1.1-.1-1.499Zm-7.193 6.095L4.196 7.507l6.695-3.697 1.298 1.299-3.696 6.694Z"></path>
|
||||
</svg>
|
||||
{{ $post->einundzwanzigPleb->profile->name }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex items-center after:block after:content-['·'] last:after:content-[''] after:text-sm after:text-gray-400 dark:after:text-gray-600 after:px-2">
|
||||
</div>
|
||||
<div
|
||||
class="flex items-center after:block after:content-['·'] last:after:content-[''] after:text-sm after:text-gray-400 dark:after:text-gray-600 after:px-2">
|
||||
<span
|
||||
class="text-gray-500">{{ $post->created_at->format('d.m.Y') }}</span>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 flex justify-end w-full space-x-2">
|
||||
<x-button
|
||||
xs
|
||||
target="_blank"
|
||||
:href="url()->temporarySignedRoute('dl', now()->addMinutes(30), ['media' => $post->getFirstMedia('pdf')])"
|
||||
label="Öffnen"
|
||||
primary icon="cloud-arrow-down"/>
|
||||
@if($canEdit)
|
||||
<x-button
|
||||
xs
|
||||
wire:click="delete({{ $post->id }})"
|
||||
wire:loading.attr="disabled"
|
||||
label="Löschen"
|
||||
negative icon="trash"/>
|
||||
@endif
|
||||
</div>
|
||||
</article>
|
||||
@empty
|
||||
<article class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<p>Keine News vorhanden.</p>
|
||||
</article>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Right content -->
|
||||
<div class="w-full mt-8 sm:mt-0 xl:w-72">
|
||||
<div
|
||||
class="lg:sticky lg:top-16 lg:h-[calc(100dvh-64px)] lg:overflow-x-hidden lg:overflow-y-auto no-scrollbar">
|
||||
<div class="md:py-8">
|
||||
|
||||
<!-- Blocks -->
|
||||
<div class="space-y-4">
|
||||
|
||||
@if($canEdit)
|
||||
<div class="bg-white dark:bg-gray-800 p-4 rounded-xl">
|
||||
<div
|
||||
class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase mb-4">
|
||||
News anlegen
|
||||
</div>
|
||||
<div class="mt-4 flex flex-col space-y-2">
|
||||
<div wire:dirty>
|
||||
<input class="text-gray-200" type="file" wire:model="file">
|
||||
@error('file')
|
||||
<span class="text-red-500">{{ $message }}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div wire:dirty>
|
||||
<x-native-select
|
||||
wire:model="form.category"
|
||||
label="Kategorie"
|
||||
placeholder="Wähle Kategorie"
|
||||
:options="\App\Enums\NewsCategory::selectOptions()"
|
||||
option-label="label" option-value="value"
|
||||
/>
|
||||
</div>
|
||||
<div wire:dirty>
|
||||
<x-input label="Titel" wire:model="form.name"/>
|
||||
</div>
|
||||
<div wire:dirty>
|
||||
<x-textarea
|
||||
description="optional"
|
||||
label="Beschreibung" wire:model="form.description"/>
|
||||
</div>
|
||||
<button
|
||||
wire:click="save"
|
||||
class="btn-sm w-full bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 text-gray-800 dark:text-gray-300">
|
||||
Hinzufügen
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
<div class="mt-2 flex justify-end w-full space-x-2">
|
||||
<x-button
|
||||
xs
|
||||
target="_blank"
|
||||
:href="url()->temporarySignedRoute('dl', now()->addMinutes(30), ['media' => $post->getFirstMedia('pdf')])"
|
||||
label="Öffnen"
|
||||
primary icon="cloud-arrow-down"/>
|
||||
@if($canEdit)
|
||||
<x-button
|
||||
xs
|
||||
wire:click="delete({{ $post->id }})"
|
||||
wire:loading.attr="disabled"
|
||||
label="Löschen"
|
||||
negative icon="trash"/>
|
||||
@endif
|
||||
</div>
|
||||
</article>
|
||||
@empty
|
||||
<article class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<p>Keine News vorhanden.</p>
|
||||
</article>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">
|
||||
News
|
||||
</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, die News einzusehen.
|
||||
</p>
|
||||
<!-- Right content -->
|
||||
<div class="w-full mt-8 sm:mt-0 xl:w-72">
|
||||
<div
|
||||
class="lg:sticky lg:top-16 lg:h-[calc(100dvh-64px)] lg:overflow-x-hidden lg:overflow-y-auto no-scrollbar">
|
||||
<div class="md:py-8">
|
||||
|
||||
<!-- Blocks -->
|
||||
<div class="space-y-4">
|
||||
|
||||
@if($canEdit)
|
||||
<div class="bg-white dark:bg-gray-800 p-4 rounded-xl">
|
||||
<div
|
||||
class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase mb-4">
|
||||
News anlegen
|
||||
</div>
|
||||
<div class="mt-4 flex flex-col space-y-2">
|
||||
<div wire:dirty>
|
||||
<input class="text-gray-200" type="file" wire:model="file">
|
||||
@error('file')
|
||||
<span class="text-red-500">{{ $message }}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div wire:dirty>
|
||||
<x-native-select
|
||||
wire:model="form.category"
|
||||
label="Kategorie"
|
||||
placeholder="Wähle Kategorie"
|
||||
:options="\App\Enums\NewsCategory::selectOptions()"
|
||||
option-label="label" option-value="value"
|
||||
/>
|
||||
</div>
|
||||
<div wire:dirty>
|
||||
<x-input label="Titel" wire:model="form.name"/>
|
||||
</div>
|
||||
<div wire:dirty>
|
||||
<x-textarea
|
||||
description="optional"
|
||||
label="Beschreibung" wire:model="form.description"/>
|
||||
</div>
|
||||
<button
|
||||
wire:click="save"
|
||||
class="btn-sm w-full bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 text-gray-800 dark:text-gray-300">
|
||||
Hinzufügen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</x-layouts.app>
|
||||
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">
|
||||
News
|
||||
</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, die News einzusehen.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,53 @@
|
||||
<x-layouts.app title="{{ __('Projektförderung anlegen') }}">
|
||||
<?php
|
||||
|
||||
use App\Models\ProjectProposal;
|
||||
use App\Support\NostrAuth;
|
||||
use Livewire\Component;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\Title;
|
||||
|
||||
new
|
||||
#[Layout('layouts.app')]
|
||||
#[Title('Projektförderung anlegen')]
|
||||
class extends Component {
|
||||
public array $form = [
|
||||
'name' => '',
|
||||
'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');
|
||||
}
|
||||
};
|
||||
?>
|
||||
|
||||
<x-layouts.app>
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
|
||||
@@ -1,74 +1,128 @@
|
||||
<x-layouts.app title="{{ __('Projektförderung bearbeiten') }}">
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div
|
||||
class="flex flex-col md:flex-row items-center mb-6 space-y-4 md:space-y-0 md:space-x-4">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<h1 class="text-2xl md:text-3xl text-gray-800 dark:text-gray-100 font-bold">
|
||||
Projektförderung bearbeiten
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
<div class="md:flex">
|
||||
<!-- Left column -->
|
||||
<div class="w-full md:w-60 mb-4 md:mb-0">
|
||||
<div
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<h2 class="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">
|
||||
Formular
|
||||
</h2>
|
||||
<div class="space-y-4">
|
||||
<div wire:dirty>
|
||||
<x-input label="Name" wire:model="form.name"/>
|
||||
@error('form.name')
|
||||
<span class="text-red-500">{{ $message }}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div wire:dirty>
|
||||
<x-textarea label="Beschreibung" wire:model="form.description"/>
|
||||
@error('form.description')
|
||||
<span class="text-red-500">{{ $message }}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<button
|
||||
wire:click="update"
|
||||
wire:loading.attr="disabled"
|
||||
class="w-full btn-sm bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 text-gray-800 dark:text-gray-300">
|
||||
Speichern
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
use App\Models\ProjectProposal;
|
||||
use App\Support\NostrAuth;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Component;
|
||||
|
||||
<!-- Right column -->
|
||||
<div class="flex-1 md:ml-8">
|
||||
<div
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<h2 class="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">
|
||||
Information
|
||||
</h2>
|
||||
<p class="text-sm text-gray-800 dark:text-gray-100">
|
||||
Bearbeite die Projektförderung und speichere deine Änderungen.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
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);
|
||||
}
|
||||
};
|
||||
?>
|
||||
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div
|
||||
class="flex flex-col md:flex-row items-center mb-6 space-y-4 md:space-y-0 md:space-x-4">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<h1 class="text-2xl md:text-3xl text-gray-800 dark:text-gray-100 font-bold">
|
||||
Projektförderung bearbeiten
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">
|
||||
Projektförderung
|
||||
</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, die Projektförderung zu bearbeiten.
|
||||
|
||||
<div class="md:flex">
|
||||
<!-- Left column -->
|
||||
<div class="w-full md:w-60 mb-4 md:mb-0">
|
||||
<div
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<h2 class="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">
|
||||
Formular
|
||||
</h2>
|
||||
<div class="space-y-4">
|
||||
<div wire:dirty>
|
||||
<x-input label="Name" wire:model="form.name"/>
|
||||
@error('form.name')
|
||||
<span class="text-red-500">{{ $message }}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div wire:dirty>
|
||||
<x-textarea label="Beschreibung" wire:model="form.description"/>
|
||||
@error('form.description')
|
||||
<span class="text-red-500">{{ $message }}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<button
|
||||
wire:click="update"
|
||||
wire:loading.attr="disabled"
|
||||
class="w-full btn-sm bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 text-gray-800 dark:text-gray-300">
|
||||
Speichern
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right column -->
|
||||
<div class="flex-1 md:ml-8">
|
||||
<div
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<h2 class="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">
|
||||
Information
|
||||
</h2>
|
||||
<p class="text-sm text-gray-800 dark:text-gray-100">
|
||||
Bearbeite die Projektförderung und speichere deine Änderungen.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</x-layouts.app>
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">
|
||||
Projektförderung
|
||||
</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, die Projektförderung zu bearbeiten.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -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')
|
||||
]);
|
||||
}
|
||||
};
|
||||
?>
|
||||
|
||||
|
||||
@@ -1,85 +1,107 @@
|
||||
<x-layouts.app
|
||||
:seo="new \RalphJSmit\Laravel\SEO\Support\SEOData(title: 'Projektförderung ' . $project->name, description: $project->description)"
|
||||
>
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div
|
||||
class="flex flex-col md:flex-row items-center mb-6 space-y-4 md:space-y-0 md:space-x-4">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<h1 class="text-2xl md:text-3xl text-gray-800 dark:text-gray-100 font-bold">
|
||||
{{ $project->name }}
|
||||
</h1>
|
||||
<div>
|
||||
@if($project->status === 'pending')
|
||||
<x-badge info label="Pending"/>
|
||||
@elseif($project->status === 'active')
|
||||
<x-badge success label="Active"/>
|
||||
@else
|
||||
<x-badge neutral label="Archiviert"/>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
<div class="md:flex">
|
||||
<!-- Left column -->
|
||||
<div class="w-full md:w-60 mb-4 md:mb-0">
|
||||
<div
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<h2 class="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">
|
||||
Details
|
||||
</h2>
|
||||
<dl class="space-y-3">
|
||||
<div>
|
||||
<dt class="text-xs font-semibold text-gray-500 uppercase mb-1">Status</dt>
|
||||
<dd class="text-sm text-gray-800 dark:text-gray-100">
|
||||
@if($project->status === 'pending')
|
||||
Ausstehend
|
||||
@elseif($project->status === 'active')
|
||||
Aktiv
|
||||
@else
|
||||
Archiviert
|
||||
@endif
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs font-semibold text-gray-500 uppercase mb-1">Erstellt am</dt>
|
||||
<dd class="text-sm text-gray-800 dark:text-gray-100">
|
||||
{{ $project->created_at->format('d.m.Y') }}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
use App\Models\ProjectProposal;
|
||||
use App\Support\NostrAuth;
|
||||
use Livewire\Component;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\Title;
|
||||
|
||||
<!-- Right column -->
|
||||
<div class="flex-1 md:ml-8">
|
||||
<div
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<h2 class="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">
|
||||
Beschreibung
|
||||
</h2>
|
||||
<p class="text-sm text-gray-800 dark:text-gray-100">
|
||||
{{ $project->description ?? 'Keine Beschreibung' }}
|
||||
</p>
|
||||
</div>
|
||||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
?>
|
||||
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div
|
||||
class="flex flex-col md:flex-row items-center mb-6 space-y-4 md:space-y-0 md:space-x-4">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<h1 class="text-2xl md:text-3xl text-gray-800 dark:text-gray-100 font-bold">
|
||||
{{ $project->name }}
|
||||
</h1>
|
||||
<div>
|
||||
@if($project->status === 'pending')
|
||||
<x-badge info label="Pending"/>
|
||||
@elseif($project->status === 'active')
|
||||
<x-badge success label="Active"/>
|
||||
@else
|
||||
<x-badge neutral label="Archiviert"/>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">
|
||||
Projektförderung
|
||||
</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, die Projektförderung einzusehen.
|
||||
|
||||
<div class="md:flex">
|
||||
<!-- Left column -->
|
||||
<div class="w-full md:w-60 mb-4 md:mb-0">
|
||||
<div
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<h2 class="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">
|
||||
Details
|
||||
</h2>
|
||||
<dl class="space-y-3">
|
||||
<div>
|
||||
<dt class="text-xs font-semibold text-gray-500 uppercase mb-1">Status</dt>
|
||||
<dd class="text-sm text-gray-800 dark:text-gray-100">
|
||||
@if($project->status === 'pending')
|
||||
Ausstehend
|
||||
@elseif($project->status === 'active')
|
||||
Aktiv
|
||||
@else
|
||||
Archiviert
|
||||
@endif
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs font-semibold text-gray-500 uppercase mb-1">Erstellt am</dt>
|
||||
<dd class="text-sm text-gray-800 dark:text-gray-100">
|
||||
{{ $project->created_at->format('d.m.Y') }}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right column -->
|
||||
<div class="flex-1 md:ml-8">
|
||||
<div
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<h2 class="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">
|
||||
Beschreibung
|
||||
</h2>
|
||||
<p class="text-sm text-gray-800 dark:text-gray-100">
|
||||
{{ $project->description ?? 'Keine Beschreibung' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</x-layouts.app>
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">
|
||||
Projektförderung
|
||||
</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, die Projektförderung einzusehen.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user