Feste Profilfelder in Formularen, Geburtstage, anpassbare Startseite
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m21s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m34s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 3m8s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 3m6s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m43s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m47s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m1s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m21s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m34s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 3m8s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 3m6s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m43s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m47s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m1s
- Formulare: Felder fest aus dem Profil (nicht änderbar, Server setzt den Profilwert ein), Hinweis bei fehlender Profilangabe - Geburtstage (optionales Plugin, standardmäßig aus): Tag und Monat freiwillig im Profil, Kachel, Liste /geburtstage, Pagebuilder-Block, Glückwunsch am eigenen Geburtstag; Sichtbarkeit alle/Abteilung/Standort - Startseite: Kacheln je Bereich sortieren und ausblenden; eigene Kacheln (Bild mit Link, Text, Hinweis) mit Zeitraum und Zielgruppe - Kern: optionale mitgelieferte Plugins, Startseitenbereich „top“, Profilabschnitte für Plugins, Kachel-Bezeichnungen Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
435960725d
commit
ee8dde93c0
262 changed files with 2385 additions and 692 deletions
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Freiwillige Geburtstagsliste: nur Tag und Monat – kein Geburtsjahr, kein Alter.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('birthdays', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->unique()->constrained('users')->cascadeOnDelete();
|
||||
$table->unsignedTinyInteger('month');
|
||||
$table->unsignedTinyInteger('day');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['month', 'day']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('birthdays');
|
||||
}
|
||||
};
|
||||
14
plugins-core/birthdays/plugin.json
Normal file
14
plugins-core/birthdays/plugin.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"slug": "birthdays",
|
||||
"name": "Geburtstage",
|
||||
"version": "1.0.0",
|
||||
"description": "Geburtstagsliste zum Mitmachen: Wer möchte, trägt Tag und Monat im Profil ein. Mit Kachel auf der Startseite und Glückwunsch am eigenen Geburtstag.",
|
||||
"author": "Inhaus",
|
||||
"namespace": "Inhaus\\Plugins\\Birthdays\\",
|
||||
"class": "Inhaus\\Plugins\\Birthdays\\BirthdaysPlugin",
|
||||
"enabled_by_default": false,
|
||||
"requires": {
|
||||
"core": ">=0.6.0",
|
||||
"php": ">=8.3"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<script setup>
|
||||
import BirthdayItem from '../components/BirthdayItem.vue';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section>
|
||||
<h3 v-if="block.data.title" class="mb-3 text-lg font-semibold">{{ block.data.title }}</h3>
|
||||
<div class="divide-y rounded-lg border bg-card px-4">
|
||||
<BirthdayItem v-for="item in block.props?.birthdays ?? []" :key="`${item.person.id}-${item.date}`" :item="item" />
|
||||
<p v-if="!(block.props?.birthdays ?? []).length" class="py-3 text-sm text-muted-foreground">Keine anstehenden Geburtstage.</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { Cake } from '@lucide/vue';
|
||||
import PersonAvatar from '@/components/PersonAvatar.vue';
|
||||
|
||||
defineProps({
|
||||
item: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const day = (iso) => new Intl.DateTimeFormat('de-DE', { day: 'numeric', month: 'long' }).format(new Date(`${iso}T12:00:00`));
|
||||
const weekday = (iso) => new Intl.DateTimeFormat('de-DE', { weekday: 'short' }).format(new Date(`${iso}T12:00:00`));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Link :href="`/personen/${item.person.id}`" class="group flex items-center gap-3 py-2.5">
|
||||
<span class="relative shrink-0">
|
||||
<PersonAvatar :person="item.person" class="size-10" />
|
||||
<span v-if="item.today" class="absolute -right-1 -bottom-1 grid size-5 place-items-center rounded-full bg-brand text-brand-foreground ring-2 ring-card"><Cake class="size-3" /></span>
|
||||
</span>
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="block truncate text-sm font-medium group-hover:underline">{{ item.person.name }}</span>
|
||||
<span class="block truncate text-xs text-muted-foreground">{{ item.person.job_title || item.person.department }}</span>
|
||||
</span>
|
||||
<span class="shrink-0 text-right text-xs" :class="item.today ? 'font-semibold text-brand-text' : 'text-muted-foreground'">
|
||||
{{ item.today ? 'Heute' : `${weekday(item.date)}, ${day(item.date)}` }}
|
||||
</span>
|
||||
</Link>
|
||||
</template>
|
||||
52
plugins-core/birthdays/resources/js/pages/Index.vue
Normal file
52
plugins-core/birthdays/resources/js/pages/Index.vue
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { Cake } from '@lucide/vue';
|
||||
import EmptyState from '@/components/EmptyState.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import BirthdayItem from '../components/BirthdayItem.vue';
|
||||
|
||||
const props = defineProps({
|
||||
birthdays: { type: Array, required: true },
|
||||
scope: { type: String, required: true },
|
||||
registered: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
// Nach Tagen gruppiert: „Heute“, dann die folgenden Tage
|
||||
const groups = computed(() => {
|
||||
const result = [];
|
||||
|
||||
for (const item of props.birthdays) {
|
||||
const last = result.at(-1);
|
||||
last && last.date === item.date ? last.items.push(item) : result.push({ date: item.date, today: item.today, items: [item] });
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
const label = (group) => group.today ? 'Heute' : new Intl.DateTimeFormat('de-DE', { weekday: 'long', day: 'numeric', month: 'long' }).format(new Date(`${group.date}T12:00:00`));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout title="Geburtstage">
|
||||
<div class="mx-auto max-w-3xl">
|
||||
<h1 class="text-2xl font-semibold tracking-tight">Geburtstage</h1>
|
||||
<p class="mt-1 text-sm text-muted-foreground">Die nächsten 30 Tage · {{ scope }}</p>
|
||||
|
||||
<p v-if="!registered" class="mt-5 rounded-lg border bg-card px-4 py-3 text-sm">
|
||||
Sie möchten auch in der Liste stehen? Tragen Sie Tag und Monat unter
|
||||
<Link href="/profil/bearbeiten" class="font-medium text-brand-text hover:underline">Profil bearbeiten</Link> ein.
|
||||
</p>
|
||||
|
||||
<div v-if="groups.length" class="mt-6 grid gap-5">
|
||||
<section v-for="group in groups" :key="group.date" class="rounded-lg border bg-card">
|
||||
<h2 class="border-b px-5 py-3 text-sm font-semibold" :class="group.today ? 'text-brand-text' : ''">{{ label(group) }}</h2>
|
||||
<div class="divide-y px-5">
|
||||
<BirthdayItem v-for="item in group.items" :key="item.person.id" :item="item" />
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div v-else class="mt-6 rounded-lg border bg-card"><EmptyState :icon="Cake" title="Keine Geburtstage in den nächsten 30 Tagen" /></div>
|
||||
</div>
|
||||
</AppLayout>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { router, useForm } from '@inertiajs/vue3';
|
||||
import { Cake, LoaderCircle } from '@lucide/vue';
|
||||
import { toast } from 'vue-sonner';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import FormField from '@/components/FormField.vue';
|
||||
import NativeSelect from '@/components/NativeSelect.vue';
|
||||
import Panel from '@/components/Panel.vue';
|
||||
|
||||
const props = defineProps({
|
||||
birthday: { type: Object, default: null },
|
||||
months: { type: Array, required: true },
|
||||
scope: { type: String, default: 'all' },
|
||||
});
|
||||
|
||||
const form = useForm({ day: props.birthday?.day ?? null, month: props.birthday?.month ?? null });
|
||||
const days = computed(() => Array.from({ length: 31 }, (_, i) => ({ value: i + 1, label: String(i + 1) })));
|
||||
|
||||
const audience = { all: 'allen Mitarbeitenden', department: 'Ihrer Abteilung', location: 'Ihrem Standort' };
|
||||
|
||||
function save() {
|
||||
form.put('/profil/geburtstag', {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
form.defaults();
|
||||
toast.success('Geburtstag gespeichert');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function remove() {
|
||||
router.delete('/profil/geburtstag', {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
form.day = null;
|
||||
form.month = null;
|
||||
form.defaults();
|
||||
toast.success('Aus der Geburtstagsliste entfernt');
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Panel title="Geburtstag">
|
||||
<form class="grid gap-4" @submit.prevent="save">
|
||||
<p class="flex gap-2 text-sm text-muted-foreground">
|
||||
<Cake class="mt-0.5 size-4 shrink-0 text-brand-text" />
|
||||
<span>Freiwillig: Wenn Sie Tag und Monat eintragen, erscheint Ihr Geburtstag in der Geburtstagsliste und ist {{ audience[scope] }} sichtbar. Das Geburtsjahr wird nicht erfasst. Austragen ist jederzeit möglich.</span>
|
||||
</p>
|
||||
<div class="grid grid-cols-2 gap-4 sm:max-w-sm">
|
||||
<FormField id="birthday-day" label="Tag" :error="form.errors.day">
|
||||
<NativeSelect id="birthday-day" v-model="form.day" :options="days" placeholder="–" />
|
||||
</FormField>
|
||||
<FormField id="birthday-month" label="Monat" :error="form.errors.month">
|
||||
<NativeSelect id="birthday-month" v-model="form.month" :options="months" placeholder="–" />
|
||||
</FormField>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2 border-t pt-4">
|
||||
<Button v-if="birthday" type="button" variant="ghost" class="text-destructive hover:text-destructive" @click="remove">Austragen</Button>
|
||||
<Button type="submit" :disabled="form.processing || !form.day || !form.month || !form.isDirty">
|
||||
<LoaderCircle v-if="form.processing" class="animate-spin" />
|
||||
{{ birthday ? 'Speichern' : 'Eintragen' }}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Panel>
|
||||
</template>
|
||||
55
plugins-core/birthdays/resources/js/widgets/Greeting.vue
Normal file
55
plugins-core/birthdays/resources/js/widgets/Greeting.vue
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { Cake, X } from '@lucide/vue';
|
||||
|
||||
/**
|
||||
* Glückwunsch am eigenen Geburtstag – lässt sich für heute ausblenden.
|
||||
*/
|
||||
const props = defineProps({
|
||||
name: { type: String, required: true },
|
||||
});
|
||||
|
||||
const key = `inhaus.birthday-greeting.${new Date().toISOString().slice(0, 10)}`;
|
||||
const hidden = ref(false);
|
||||
|
||||
try {
|
||||
hidden.value = localStorage.getItem(key) === '1';
|
||||
} catch {
|
||||
// Speicher nicht verfügbar – dann eben immer zeigen.
|
||||
}
|
||||
|
||||
function dismiss() {
|
||||
hidden.value = true;
|
||||
|
||||
try {
|
||||
localStorage.setItem(key, '1');
|
||||
} catch {
|
||||
// ignorieren
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section v-if="!hidden" class="relative overflow-hidden rounded-lg bg-brand text-brand-foreground" role="status">
|
||||
<!-- dezente Konfetti-Punkte -->
|
||||
<svg class="pointer-events-none absolute inset-0 size-full opacity-25" aria-hidden="true">
|
||||
<circle cx="8%" cy="30%" r="4" fill="currentColor" />
|
||||
<circle cx="15%" cy="75%" r="3" fill="currentColor" />
|
||||
<rect x="24%" y="18%" width="7" height="7" transform="rotate(20)" fill="currentColor" />
|
||||
<circle cx="62%" cy="20%" r="3" fill="currentColor" />
|
||||
<circle cx="78%" cy="70%" r="5" fill="currentColor" />
|
||||
<rect x="88%" y="30%" width="8" height="8" fill="currentColor" />
|
||||
<circle cx="94%" cy="80%" r="3" fill="currentColor" />
|
||||
</svg>
|
||||
<div class="relative flex items-center gap-4 px-5 py-5 sm:px-8">
|
||||
<span class="grid size-12 shrink-0 place-items-center rounded-full bg-white/15"><Cake class="size-6" /></span>
|
||||
<div class="min-w-0 flex-1">
|
||||
<p class="text-xl font-semibold tracking-tight">Alles Gute zum Geburtstag, {{ props.name }}!</p>
|
||||
<p class="mt-0.5 text-sm opacity-90">Wir wünschen Ihnen einen schönen Tag.</p>
|
||||
</div>
|
||||
<button type="button" class="grid size-9 shrink-0 place-items-center rounded-md hover:bg-white/15" aria-label="Glückwunsch ausblenden" @click="dismiss">
|
||||
<X class="size-5" />
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
17
plugins-core/birthdays/resources/js/widgets/Upcoming.vue
Normal file
17
plugins-core/birthdays/resources/js/widgets/Upcoming.vue
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<script setup>
|
||||
import Panel from '@/components/Panel.vue';
|
||||
import BirthdayItem from '../components/BirthdayItem.vue';
|
||||
|
||||
defineProps({
|
||||
birthdays: { type: Array, required: true },
|
||||
days: { type: Number, default: 7 },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Panel title="Geburtstage" action-label="Alle" action-href="/geburtstage">
|
||||
<div class="-my-2 divide-y">
|
||||
<BirthdayItem v-for="item in birthdays" :key="`${item.person.id}-${item.date}`" :item="item" />
|
||||
</div>
|
||||
</Panel>
|
||||
</template>
|
||||
10
plugins-core/birthdays/routes/web.php
Normal file
10
plugins-core/birthdays/routes/web.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Inhaus\Plugins\Birthdays\Http\Controllers\BirthdayController;
|
||||
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::get('/geburtstage', [BirthdayController::class, 'index'])->name('birthdays.index');
|
||||
Route::put('/profil/geburtstag', [BirthdayController::class, 'update'])->name('birthdays.update');
|
||||
Route::delete('/profil/geburtstag', [BirthdayController::class, 'destroy'])->name('birthdays.destroy');
|
||||
});
|
||||
95
plugins-core/birthdays/src/BirthdayList.php
Normal file
95
plugins-core/birthdays/src/BirthdayList.php
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Birthdays;
|
||||
|
||||
use App\Http\Resources\PersonResource;
|
||||
use App\Models\User;
|
||||
use App\Support\Settings;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Inhaus\Plugins\Birthdays\Models\Birthday;
|
||||
|
||||
/**
|
||||
* Anstehende Geburtstage für eine Person – je nach Einstellung aus dem ganzen
|
||||
* Haus, der eigenen Abteilung oder dem eigenen Standort.
|
||||
*/
|
||||
class BirthdayList
|
||||
{
|
||||
public const SCOPES = [
|
||||
'all' => 'Alle Mitarbeitenden',
|
||||
'department' => 'Nur die eigene Abteilung',
|
||||
'location' => 'Nur der eigene Standort',
|
||||
];
|
||||
|
||||
public function __construct(private readonly Settings $settings) {}
|
||||
|
||||
public function scope(): string
|
||||
{
|
||||
return array_key_exists($s = (string) $this->settings->get('birthdays.scope', 'all'), self::SCOPES) ? $s : 'all';
|
||||
}
|
||||
|
||||
public function daysAhead(): int
|
||||
{
|
||||
return max(0, min(60, (int) $this->settings->get('birthdays.days', 7)));
|
||||
}
|
||||
|
||||
public function greetingEnabled(): bool
|
||||
{
|
||||
return (bool) $this->settings->get('birthdays.greeting', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{date: string, today: bool, person: array<string, mixed>}>
|
||||
*/
|
||||
public function upcoming(User $viewer, ?int $days = null, ?string $scope = null, int $limit = 200): array
|
||||
{
|
||||
$days ??= $this->daysAhead();
|
||||
$scope ??= $this->scope();
|
||||
$today = Carbon::today();
|
||||
$end = $today->copy()->addDays($days);
|
||||
|
||||
// Nur die betroffenen Monate laden (höchstens drei), dann genau filtern.
|
||||
$months = collect(range(0, (int) $today->copy()->startOfMonth()->diffInMonths($end->copy()->startOfMonth())))
|
||||
->map(fn ($i) => $today->copy()->startOfMonth()->addMonths($i)->month)->unique()->values()->all();
|
||||
|
||||
$birthdays = Birthday::query()
|
||||
->whereIn('month', $months)
|
||||
->whereHas('user', function ($q) use ($viewer, $scope) {
|
||||
$q->where('is_active', true);
|
||||
|
||||
if ($scope === 'department') {
|
||||
$viewer->department ? $q->where('department', $viewer->department) : $q->whereKey($viewer->id);
|
||||
} elseif ($scope === 'location') {
|
||||
$viewer->location ? $q->where('location', $viewer->location) : $q->whereKey($viewer->id);
|
||||
}
|
||||
})
|
||||
->with('user')
|
||||
->get();
|
||||
|
||||
return $birthdays
|
||||
->map(fn (Birthday $b) => ['birthday' => $b, 'date' => $b->nextOccurrence($today)])
|
||||
->filter(fn ($row) => $row['date']->lte($end))
|
||||
->sortBy(fn ($row) => $row['date']->format('Ymd').mb_strtolower($row['birthday']->user->last_name.' '.$row['birthday']->user->first_name))
|
||||
->take($limit)
|
||||
->map(fn ($row) => [
|
||||
'date' => $row['date']->toDateString(),
|
||||
'today' => $row['date']->isSameDay($today),
|
||||
'person' => (new PersonResource($row['birthday']->user))->resolve(),
|
||||
])
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
public function isBirthdayToday(User $user): bool
|
||||
{
|
||||
return (bool) Birthday::query()->where('user_id', $user->id)->first()?->isOn(Carbon::today());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, string>
|
||||
*/
|
||||
public static function months(): Collection
|
||||
{
|
||||
return collect(range(1, 12))->mapWithKeys(fn ($m) => [$m => Carbon::create(2000, $m, 1)->locale('de')->translatedFormat('F')]);
|
||||
}
|
||||
}
|
||||
60
plugins-core/birthdays/src/BirthdaysPlugin.php
Normal file
60
plugins-core/birthdays/src/BirthdaysPlugin.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Birthdays;
|
||||
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Models\User;
|
||||
use App\Pagebuilder\Blocks;
|
||||
use App\Pagebuilder\BlockType;
|
||||
use App\Pagebuilder\Field;
|
||||
use App\Plugins\Plugin;
|
||||
use App\Profile\ProfileSections;
|
||||
use Inhaus\Plugins\Birthdays\Models\Birthday;
|
||||
|
||||
/**
|
||||
* Freiwillige Geburtstagsliste. Standardmäßig aus – im Admin unter „Plugins“ aktivierbar.
|
||||
*/
|
||||
class BirthdaysPlugin extends Plugin
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->singleton(BirthdayList::class);
|
||||
|
||||
$this->app->make(ProfileSections::class)->add('birthday', 'birthdays::ProfileBirthday', 10, function (User $user) {
|
||||
$birthday = Birthday::query()->where('user_id', $user->id)->first();
|
||||
|
||||
return [
|
||||
'birthday' => $birthday ? ['day' => $birthday->day, 'month' => $birthday->month] : null,
|
||||
'months' => BirthdayList::months()->map(fn ($label, $value) => ['value' => $value, 'label' => $label])->values(),
|
||||
'scope' => app(BirthdayList::class)->scope(),
|
||||
];
|
||||
});
|
||||
|
||||
$widgets = $this->app->make(Widgets::class);
|
||||
|
||||
// Glückwunsch oben auf der Startseite – nur am eigenen Geburtstag.
|
||||
$widgets->add('birthdays.greeting', 'birthdays::Greeting', 'top', sort: 0, props: function (User $user) {
|
||||
$list = app(BirthdayList::class);
|
||||
|
||||
return $list->greetingEnabled() && $list->isBirthdayToday($user) ? ['name' => $user->first_name ?: $user->name] : null;
|
||||
}, label: 'Geburtstagsgruß (am eigenen Geburtstag)', mobileSort: -100);
|
||||
|
||||
$widgets->add('birthdays.upcoming', 'birthdays::Upcoming', 'aside', sort: 30, props: function (User $user) {
|
||||
$list = app(BirthdayList::class);
|
||||
$upcoming = $list->upcoming($user, limit: 8);
|
||||
|
||||
return $upcoming === [] ? null : ['birthdays' => $upcoming, 'days' => $list->daysAhead()];
|
||||
}, label: 'Geburtstage', mobileSort: 35);
|
||||
|
||||
$this->app->make(Blocks::class)->add(BlockType::make('birthdays.list', 'Geburtstage', 'cake', 'dynamic', 'birthdays::BirthdaysBlock')
|
||||
->description('Anstehende Geburtstage – z. B. auf der Seite einer Abteilung.')
|
||||
->fields([
|
||||
Field::text('title', 'Überschrift', 150, 'Geburtstage'),
|
||||
Field::select('scope', 'Wessen Geburtstage', ['' => 'Wie in den Einstellungen'] + BirthdayList::SCOPES, ''),
|
||||
Field::number('days', 'Tage im Voraus', 0, 60, 14),
|
||||
])
|
||||
->resolveUsing(fn (array $data, ?User $user) => $user ? [
|
||||
'birthdays' => app(BirthdayList::class)->upcoming($user, $data['days'], $data['scope'] ?: null, 30),
|
||||
] : null));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Birthdays\Filament\Pages;
|
||||
|
||||
use App\Support\Settings;
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Inhaus\Plugins\Birthdays\BirthdayList;
|
||||
use Inhaus\Plugins\Birthdays\Models\Birthday;
|
||||
use UnitEnum;
|
||||
|
||||
class BirthdaySettings extends Page
|
||||
{
|
||||
protected string $view = 'filament.pages.settings-form';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCake;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Portal';
|
||||
|
||||
protected static ?int $navigationSort = 30;
|
||||
|
||||
protected static ?string $navigationLabel = 'Geburtstage';
|
||||
|
||||
protected static ?string $title = 'Geburtstage';
|
||||
|
||||
protected static ?string $slug = 'geburtstage';
|
||||
|
||||
/** @var array<string, mixed>|null */
|
||||
public ?array $data = [];
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('appearance.manage') ?? false;
|
||||
}
|
||||
|
||||
public function mount(BirthdayList $list): void
|
||||
{
|
||||
$this->form->fill(['scope' => $list->scope(), 'days' => $list->daysAhead(), 'greeting' => $list->greetingEnabled()]);
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->statePath('data')->components([
|
||||
Section::make('Geburtstagsliste')
|
||||
->description(fn () => 'Mitarbeitende tragen sich freiwillig im Profil ein (nur Tag und Monat). Derzeit eingetragen: '.Birthday::query()->count().'.')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('scope')->label('Wer sieht wessen Geburtstag')->options(BirthdayList::SCOPES)->required()->native(false),
|
||||
TextInput::make('days')->label('Tage im Voraus auf der Startseite')->numeric()->minValue(0)->maxValue(60)->required(),
|
||||
Toggle::make('greeting')->label('Am eigenen Geburtstag auf der Startseite gratulieren')->columnSpanFull(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function save(Settings $settings): void
|
||||
{
|
||||
$state = $this->form->getState();
|
||||
$settings->setMany(['birthdays.scope' => $state['scope'], 'birthdays.days' => (int) $state['days'], 'birthdays.greeting' => (bool) $state['greeting']]);
|
||||
|
||||
Notification::make()->success()->title('Gespeichert')->send();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Birthdays\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Inhaus\Plugins\Birthdays\BirthdayList;
|
||||
use Inhaus\Plugins\Birthdays\Models\Birthday;
|
||||
|
||||
class BirthdayController extends Controller
|
||||
{
|
||||
public function index(Request $request, BirthdayList $list): Response
|
||||
{
|
||||
return Inertia::render('birthdays::Index', [
|
||||
'birthdays' => $list->upcoming($request->user(), 30),
|
||||
'scope' => BirthdayList::SCOPES[$list->scope()],
|
||||
'registered' => Birthday::query()->where('user_id', $request->user()->id)->exists(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request): RedirectResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'day' => ['required', 'integer', 'between:1,31'],
|
||||
'month' => ['required', 'integer', 'between:1,12'],
|
||||
], [], ['day' => 'Tag', 'month' => 'Monat']);
|
||||
|
||||
// Gültiger Tag im Monat (29. Februar erlaubt).
|
||||
if (! checkdate($data['month'], $data['day'], 2000)) {
|
||||
throw ValidationException::withMessages(['day' => 'Diesen Tag gibt es im gewählten Monat nicht.']);
|
||||
}
|
||||
|
||||
Birthday::query()->updateOrCreate(['user_id' => $request->user()->id], $data);
|
||||
|
||||
return back()->with('status', 'birthday-saved');
|
||||
}
|
||||
|
||||
public function destroy(Request $request): RedirectResponse
|
||||
{
|
||||
Birthday::query()->where('user_id', $request->user()->id)->delete();
|
||||
|
||||
return back()->with('status', 'birthday-removed');
|
||||
}
|
||||
}
|
||||
46
plugins-core/birthdays/src/Models/Birthday.php
Normal file
46
plugins-core/birthdays/src/Models/Birthday.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Birthdays\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
#[Fillable(['user_id', 'month', 'day'])]
|
||||
class Birthday extends Model
|
||||
{
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Nächster Geburtstag ab $from (heute eingeschlossen). Der 29. Februar
|
||||
* wird in Nicht-Schaltjahren am 28. Februar gefeiert.
|
||||
*/
|
||||
public function nextOccurrence(Carbon $from): Carbon
|
||||
{
|
||||
$date = self::inYear($from->year, $this->month, $this->day);
|
||||
|
||||
return $date->lt($from->copy()->startOfDay()) ? self::inYear($from->year + 1, $this->month, $this->day) : $date;
|
||||
}
|
||||
|
||||
public function isOn(Carbon $date): bool
|
||||
{
|
||||
return self::inYear($date->year, $this->month, $this->day)->isSameDay($date);
|
||||
}
|
||||
|
||||
private static function inYear(int $year, int $month, int $day): Carbon
|
||||
{
|
||||
if ($month === 2 && $day === 29 && ! Carbon::create($year)->isLeapYear()) {
|
||||
$day = 28;
|
||||
}
|
||||
|
||||
return Carbon::create($year, $month, $day)->startOfDay();
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ class EventsPlugin extends Plugin
|
|||
|
||||
$this->app->make(Widgets::class)->add('events.upcoming', 'events::Upcoming', 'aside', sort: 20, props: fn (User $user) => [
|
||||
'events' => EventResource::collection(Event::query()->upcoming()->visibleTo($user)->limit(4)->get())->resolve(),
|
||||
], mobileSort: 30);
|
||||
], label: 'Termine', mobileSort: 30);
|
||||
|
||||
$this->app->make(Blocks::class)->add(BlockType::make('events.upcoming', 'Termine', 'calendar-days', 'dynamic', 'events::UpcomingEvents')
|
||||
->description('Die nächsten Termine.')
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useForm, usePage } from '@inertiajs/vue3';
|
||||
import { CircleCheck, EyeOff, LoaderCircle, Paperclip, Send, X } from '@lucide/vue';
|
||||
import { CircleCheck, EyeOff, LoaderCircle, Lock, Paperclip, Send, X } from '@lucide/vue';
|
||||
import { toast } from 'vue-sonner';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
|
|
@ -176,6 +176,12 @@ const fieldId = (field) => `f${props.form.id}-${field.key}`;
|
|||
</label>
|
||||
</div>
|
||||
|
||||
<div v-else-if="field.locked" class="flex h-9 items-center gap-2 rounded-md border border-input bg-muted/60 px-3 text-sm" :aria-describedby="`${fieldId(field)}-locked`">
|
||||
<Lock class="size-3.5 shrink-0 text-muted-foreground" />
|
||||
<span v-if="data.answers[field.key]" :id="fieldId(field)" class="truncate">{{ data.answers[field.key] }}</span>
|
||||
<span v-else class="text-muted-foreground italic">{{ preview ? 'wird aus dem Profil übernommen' : 'nicht im Profil hinterlegt' }}</span>
|
||||
</div>
|
||||
|
||||
<Input
|
||||
v-else
|
||||
:id="fieldId(field)"
|
||||
|
|
@ -189,7 +195,11 @@ const fieldId = (field) => `f${props.form.id}-${field.key}`;
|
|||
/>
|
||||
</template>
|
||||
|
||||
<p v-if="error(field)" class="text-[13px] text-destructive">{{ error(field) }}</p>
|
||||
<p v-if="error(field)" class="text-[13px] text-destructive">
|
||||
{{ error(field) }}
|
||||
<a v-if="field.locked" href="/profil/bearbeiten" class="font-medium underline">Profil öffnen</a>
|
||||
</p>
|
||||
<p v-else-if="field.locked" :id="`${fieldId(field)}-locked`" class="text-[13px] text-muted-foreground">Aus Ihrem Profil – nicht änderbar.</p>
|
||||
<p v-else-if="field.help" class="text-[13px] text-muted-foreground">
|
||||
{{ field.help }}<template v-if="field.type === 'file' && field.max_size"> (höchstens {{ field.max_size }} MB)</template>
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import { computed, inject } from 'vue';
|
||||
import { Asterisk, Calendar, ChevronDown, Copy, GitBranch, GripVertical, Paperclip, Plus, Trash2, X } from '@lucide/vue';
|
||||
import { Asterisk, Calendar, ChevronDown, Copy, GitBranch, GripVertical, Lock, Paperclip, Plus, Trash2, X } from '@lucide/vue';
|
||||
import { fieldTypes, layoutTypes, operators, optionTypes } from '../../lib/fields';
|
||||
|
||||
/**
|
||||
|
|
@ -95,6 +95,9 @@ const fake = 'flex h-9 w-full items-center rounded-md border border-input bg-car
|
|||
<button type="button" class="grid size-6 place-items-center rounded text-destructive hover:bg-destructive/10" title="Entfernen" @click="builder.remove(field._id)"><Trash2 class="size-3.5" /></button>
|
||||
</div>
|
||||
|
||||
<p v-if="d.prefill && !d.locked && !isLayout" class="mb-1.5 mr-1 inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground">
|
||||
Vorbelegt: {{ builder.prefillOptions.find((o) => o.value === d.prefill)?.label ?? d.prefill }}
|
||||
</p>
|
||||
<p v-if="conditionText" class="mb-1.5 inline-flex items-center gap-1 rounded bg-amber-100 px-1.5 py-0.5 text-[11px] text-amber-800 dark:bg-amber-900/50 dark:text-amber-200">
|
||||
<GitBranch class="size-3" /> Nur wenn {{ conditionText }}
|
||||
</p>
|
||||
|
|
@ -156,6 +159,10 @@ const fake = 'flex h-9 w-full items-center rounded-md border border-input bg-car
|
|||
|
||||
<div v-else-if="field.type === 'date'" :class="[fake, 'justify-between']">TT.MM.JJJJ <Calendar class="size-4" /></div>
|
||||
|
||||
<div v-else-if="d.locked && d.prefill" class="flex h-9 items-center gap-2 rounded-md border border-input bg-muted/60 px-3 text-sm text-muted-foreground">
|
||||
<Lock class="size-3.5" /> Aus dem Profil: {{ builder.prefillOptions.find((o) => o.value === d.prefill)?.label ?? d.prefill }} – nicht änderbar
|
||||
</div>
|
||||
|
||||
<div v-else class="rounded-md border border-input bg-card shadow-xs">
|
||||
<input v-model="d.placeholder" class="h-9 w-full bg-transparent px-3 text-sm outline-none placeholder:text-muted-foreground/50" :placeholder="field.type === 'text' ? 'Platzhalter (optional)' : ''" :disabled="field.type !== 'text'" aria-label="Platzhalter" />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -121,9 +121,20 @@ const maxSize = computed(number('max_size'));
|
|||
|
||||
<label v-if="['text', 'email', 'phone'].includes(field.type)" class="grid gap-1.5">
|
||||
<span class="text-[13px] font-medium">Vorbelegen mit</span>
|
||||
<NativeSelect :model-value="d.prefill ?? null" :options="builder.prefillOptions" placeholder="– nicht vorbelegen –" @update:model-value="(v) => (v ? (d.prefill = v) : delete d.prefill)" />
|
||||
<span class="text-xs text-muted-foreground">Aus dem Profil der ausfüllenden Person; änderbar.</span>
|
||||
<NativeSelect :model-value="d.prefill ?? null" :options="builder.prefillOptions" placeholder="– nicht vorbelegen –" @update:model-value="(v) => (v ? (d.prefill = v) : (delete d.prefill, delete d.locked))" />
|
||||
</label>
|
||||
<div v-if="['text', 'email', 'phone'].includes(field.type) && d.prefill" class="grid gap-1.5 rounded-md border p-3">
|
||||
<label class="flex items-center justify-between gap-3 text-[13px] font-medium">
|
||||
Nicht änderbar
|
||||
<Switch :model-value="!!d.locked" @update:model-value="(v) => (v ? (d.locked = true) : delete d.locked)" />
|
||||
</label>
|
||||
<span class="text-xs text-muted-foreground">
|
||||
{{ d.locked
|
||||
? 'Das Feld zeigt den Wert aus dem Profil und kann nicht geändert werden. Beim Absenden wird immer der Profilwert gespeichert.'
|
||||
: 'Das Feld ist mit dem Profilwert vorausgefüllt, kann aber geändert werden.' }}
|
||||
</span>
|
||||
<span v-if="d.locked && builder.anonymous" class="text-xs text-amber-700 dark:text-amber-300">Achtung: Das Formular ist anonym – diese Profilangabe wird trotzdem mit der Einsendung gespeichert.</span>
|
||||
</div>
|
||||
|
||||
<div v-if="['text', 'textarea', 'number', 'checkboxes'].includes(field.type)" class="grid grid-cols-2 gap-3">
|
||||
<label v-if="['number', 'checkboxes'].includes(field.type)" class="grid gap-1.5">
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ export function toFrontend(fields) {
|
|||
multiple: !!data.multiple,
|
||||
accept: accept[data.accept ?? 'any'] || undefined,
|
||||
max_size: data.max_size,
|
||||
locked: !!(data.locked && data.prefill && ['text', 'email', 'phone'].includes(type)),
|
||||
condition: data.condition_field ? { field: data.condition_field, operator: data.condition_operator ?? 'equals', value: String(data.condition_value ?? '') } : null,
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ provide('forms:builder', {
|
|||
},
|
||||
types: props.types,
|
||||
prefillOptions: props.prefillOptions,
|
||||
anonymous: props.form.anonymous,
|
||||
selectedId,
|
||||
errorIndex,
|
||||
select,
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ class FormFields
|
|||
'multiple' => (bool) ($d['multiple'] ?? false),
|
||||
'accept' => isset($d['accept']) ? implode(',', array_map(fn ($ext) => '.'.$ext, self::FILE_TYPES[$d['accept']] ?? self::FILE_TYPES['any'])) : null,
|
||||
'max_size' => $d['max_size'] ?? null,
|
||||
'locked' => self::isLocked($field),
|
||||
'condition' => filled($d['condition_field'] ?? null) ? [
|
||||
'field' => $d['condition_field'],
|
||||
'operator' => $d['condition_operator'] ?? 'equals',
|
||||
|
|
@ -149,6 +150,38 @@ class FormFields
|
|||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Feld fest aus dem Profil: nicht änderbar, beim Absenden setzt der Server den Profilwert ein.
|
||||
*
|
||||
* @param array{type: string, data: array<string, mixed>} $field
|
||||
*/
|
||||
public static function isLocked(array $field): bool
|
||||
{
|
||||
return in_array($field['type'], ['text', 'email', 'phone'], true)
|
||||
&& filled($field['data']['prefill'] ?? null)
|
||||
&& (bool) ($field['data']['locked'] ?? false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Eingaben für feste Profilfelder durch die Werte aus dem Profil ersetzen –
|
||||
* unabhängig davon, was der Browser schickt.
|
||||
*
|
||||
* @param array<string, mixed> $answers
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function applyLocked(Form $form, User $user, array $answers): array
|
||||
{
|
||||
$profile = self::prefill($form, $user);
|
||||
|
||||
foreach ($form->fields ?? [] as $field) {
|
||||
if (self::isLocked($field)) {
|
||||
$answers[$field['data']['key']] = $profile[$field['data']['key']] ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
return $answers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
|
|
@ -231,6 +264,12 @@ class FormFields
|
|||
$messages[$name.'.accepted'] = 'Bitte bestätigen.';
|
||||
}
|
||||
|
||||
if (self::isLocked($field)) {
|
||||
$messages[$name.'.required'] = 'Diese Angabe fehlt in Ihrem Profil. Bitte ergänzen Sie sie dort (Profil bearbeiten) oder wenden Sie sich an die Personalverwaltung.';
|
||||
// Profilwerte werden nicht wie Eingaben geprüft (z. B. Telefonformat).
|
||||
$rules[$name] = [$required ? 'required' : 'nullable', 'string', 'max:500'];
|
||||
}
|
||||
|
||||
if ($field['type'] === 'checkboxes') {
|
||||
$rules[$name.'.*'] = ['string', Rule::in($options)];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class FormBuilderController extends Controller
|
|||
'fields' => $form->fields ?? [],
|
||||
'url' => $form->url(),
|
||||
'submissions' => $form->submissions()->count(),
|
||||
'anonymous' => $form->isAnonymous(),
|
||||
],
|
||||
'types' => FormFields::TYPES,
|
||||
'prefillOptions' => collect(FormFields::prefillOptions())->map(fn ($label, $value) => ['value' => $value, 'label' => $label])->values(),
|
||||
|
|
@ -92,9 +93,9 @@ class FormBuilderController extends Controller
|
|||
{
|
||||
$allowed = ['label', 'key', 'required', 'help', 'width', 'condition_field', 'condition_operator', 'condition_value'];
|
||||
$allowed = [...$allowed, ...match ($type) {
|
||||
'text' => ['placeholder', 'max', 'prefill'],
|
||||
'text' => ['placeholder', 'max', 'prefill', 'locked'],
|
||||
'textarea' => ['rows', 'max'],
|
||||
'email', 'phone' => ['prefill'],
|
||||
'email', 'phone' => ['prefill', 'locked'],
|
||||
'number' => ['min', 'max'],
|
||||
'select', 'radio' => ['options'],
|
||||
'checkboxes' => ['options', 'min', 'max'],
|
||||
|
|
@ -109,7 +110,7 @@ class FormBuilderController extends Controller
|
|||
$clean['options'] = array_values(array_unique(array_filter(array_map(fn ($o) => trim((string) $o), $clean['options']), 'strlen')));
|
||||
}
|
||||
|
||||
foreach (['required', 'multiple'] as $flag) {
|
||||
foreach (['required', 'multiple', 'locked'] as $flag) {
|
||||
if (isset($clean[$flag])) {
|
||||
$clean[$flag] = (bool) $clean[$flag];
|
||||
}
|
||||
|
|
@ -133,6 +134,10 @@ class FormBuilderController extends Controller
|
|||
unset($clean['prefill']);
|
||||
}
|
||||
|
||||
if (empty($clean['prefill']) || empty($clean['locked'])) {
|
||||
unset($clean['locked']);
|
||||
}
|
||||
|
||||
if (isset($clean['condition_operator']) && ! in_array($clean['condition_operator'], ['equals', 'not_equals', 'contains', 'filled', 'empty'], true)) {
|
||||
$clean['condition_operator'] = 'equals';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ class FormController extends Controller
|
|||
$answers[$key] = is_array($files) ? $files : [$files];
|
||||
}
|
||||
|
||||
$answers = FormFields::applyLocked($form, $user, $answers);
|
||||
|
||||
[$rules, $attributes, $messages] = FormFields::rules($form, $answers);
|
||||
$validated = Validator::make(['answers' => $answers], $rules, $messages, $attributes)->validate();
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class NewsPlugin extends Plugin
|
|||
$featured = $this->featured($user);
|
||||
|
||||
return $featured->isEmpty() ? null : ['posts' => NewsPostResource::collection($featured)->resolve()];
|
||||
}, mobileSort: 10);
|
||||
}, label: 'Slider mit hervorgehobenen Beiträgen', mobileSort: 10);
|
||||
|
||||
$widgets->add('news.latest', 'news::Latest', 'feed', sort: 10, props: function (User $user, Request $request) {
|
||||
$posts = NewsPost::query()->published()->visibleTo($user)->with('category')
|
||||
|
|
@ -84,7 +84,7 @@ class NewsPlugin extends Plugin
|
|||
'posts' => NewsPostResource::collection($posts)->resolve(),
|
||||
'canWrite' => $user->can('news.manage'),
|
||||
];
|
||||
}, mobileSort: 20);
|
||||
}, label: 'Neuigkeiten', mobileSort: 20);
|
||||
|
||||
$widgets->add('news.areas', 'news::Areas', 'main', sort: 20, props: function (User $user) {
|
||||
$posts = NewsPost::query()->published()->visibleTo($user)->with('category')
|
||||
|
|
@ -92,7 +92,7 @@ class NewsPlugin extends Plugin
|
|||
->latest('published_at')->skip(4)->limit(4)->get();
|
||||
|
||||
return $posts->isEmpty() ? null : ['posts' => NewsPostResource::collection($posts)->resolve()];
|
||||
}, mobileSort: 50);
|
||||
}, label: 'Aktuelles aus den Bereichen', mobileSort: 50);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue