Frag das Portal durchsucht alles, neue Demo-Inhalte (0.66.0)
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.3 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.4 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.4 (pull_request) Has been skipped
CI / Browser-Tests (pull_request) Successful in 8m33s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 9m8s
CI / PHP 8.3 / mysql:8.4-1 (pull_request) Successful in 17m55s
CI / Build-Artefakte aktuell (pull_request) Successful in 9m50s
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.3 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.4 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.4 (pull_request) Has been skipped
CI / Browser-Tests (pull_request) Successful in 8m33s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 9m8s
CI / PHP 8.3 / mysql:8.4-1 (pull_request) Successful in 17m55s
CI / Build-Artefakte aktuell (pull_request) Successful in 9m50s
- Wissensquellen: Termine, Downloads, Formulare, Stellen, Ideen, Umfragen, Personen, eigene IT-Tickets/Geräte (OpenNIT, je Anfrage zwischengespeichert) - Ranking mit IDF, Abfrage je Begriff, Abkürzungen als ganze Wörter, LIKE unabhängig von Groß-/Kleinschreibung (JSON-Spalten), Datum im Prompt - Demo-Inhalte für einen Träger der Eingliederungshilfe (DemoData), mehrseitige PDFs, vorhandene Inhalte je Bereich entfernen Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1656cd8090
commit
3addc09c38
165 changed files with 2258 additions and 814 deletions
30
plugins-core/downloads/src/DownloadKnowledge.php
Normal file
30
plugins-core/downloads/src/DownloadKnowledge.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Downloads;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use Inhaus\Plugins\Downloads\Models\Download;
|
||||
|
||||
/** Wissensquelle für „Frag das Portal“: Dateien in Download-Ordnern, die die Person sieht (Titel und Beschreibung) */
|
||||
class DownloadKnowledge
|
||||
{
|
||||
public function __construct(private readonly FolderTree $tree) {}
|
||||
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
$query = Download::query()->whereIn('folder_id', $this->tree->visibleIds($user) ?: [0])->whereNotNull('current_version_id')->with('folder');
|
||||
Knowledge::whereAny($query, ['title', 'description'], $terms);
|
||||
|
||||
return $query->orderBy('title')->limit($limit)->get()->map(fn (Download $download) => [
|
||||
'title' => $download->title,
|
||||
'url' => '/downloads/ordner/'.$download->folder_id,
|
||||
'text' => trim('Datei zum Herunterladen im Ordner „'.$download->folder?->name.'“. '.$download->description),
|
||||
'meta' => $download->folder?->name,
|
||||
])->all();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Inhaus\Plugins\Downloads;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Models\User;
|
||||
use App\Pagebuilder\Blocks;
|
||||
|
|
@ -21,6 +22,7 @@ class DownloadsPlugin extends Plugin
|
|||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->make(Knowledge::class)->add('downloads', 'Downloads', fn (...$args) => app(DownloadKnowledge::class)(...$args));
|
||||
$this->app->make(GlobalSearch::class)->add('downloads', 'Downloads', 'folder-down', fn (...$args) => app(DownloadSearch::class)(...$args), sort: 40);
|
||||
|
||||
$this->app->singleton(FolderTree::class);
|
||||
|
|
|
|||
67
plugins-core/events/src/EventKnowledge.php
Normal file
67
plugins-core/events/src/EventKnowledge.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Events;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
|
||||
/** Wissensquelle für „Frag das Portal“: kommende und kürzlich vergangene Termine, die die Person sieht */
|
||||
class EventKnowledge
|
||||
{
|
||||
public function __construct(private readonly Registrations $registrations) {}
|
||||
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
$query = Event::query()->visibleTo($user)->where('is_published', true)
|
||||
// Alte Termine verwirren nur („Wann ist das Sommerfest?“ meint das nächste)
|
||||
->whereRaw('COALESCE(ends_at, starts_at) >= ?', [now()->subDays(60)]);
|
||||
Knowledge::whereAny($query, ['title', 'description', 'location'], $terms);
|
||||
|
||||
return $query->orderByRaw('COALESCE(ends_at, starts_at) < ?', [now()])->orderBy('starts_at')->limit($limit)->get()
|
||||
->map(fn (Event $event) => [
|
||||
'title' => $event->title,
|
||||
'url' => '/termine/'.$event->id,
|
||||
'text' => $this->facts($event)."\n".Knowledge::plain($event->description_html ?? $event->description),
|
||||
'meta' => $this->when($event),
|
||||
])->all();
|
||||
}
|
||||
|
||||
private function when(Event $event): string
|
||||
{
|
||||
$start = $event->starts_at->locale('de');
|
||||
|
||||
if ($event->all_day) {
|
||||
return $start->translatedFormat('l, j. F Y').($event->ends_at && ! $event->ends_at->isSameDay($start) ? ' bis '.$event->ends_at->locale('de')->translatedFormat('l, j. F Y') : '').' (ganztägig)';
|
||||
}
|
||||
|
||||
return $start->translatedFormat('l, j. F Y, H:i').' Uhr'.($event->ends_at ? ' bis '.($event->ends_at->isSameDay($start) ? $event->ends_at->format('H:i') : $event->ends_at->locale('de')->translatedFormat('j. F Y, H:i')).' Uhr' : '');
|
||||
}
|
||||
|
||||
private function facts(Event $event): string
|
||||
{
|
||||
$lines = ['Termin: '.$this->when($event).'.'];
|
||||
|
||||
if ($event->location) {
|
||||
$lines[] = 'Ort: '.$event->location.'.';
|
||||
}
|
||||
|
||||
if ($event->online_url) {
|
||||
$lines[] = 'Auch online möglich.';
|
||||
}
|
||||
|
||||
if (($event->ends_at ?? $event->starts_at)->isPast()) {
|
||||
$lines[] = 'Dieser Termin ist bereits vorbei.';
|
||||
} elseif ($event->registration_enabled) {
|
||||
$free = $event->capacity === null ? null : max(0, $event->capacity - $this->registrations->confirmedCount($event));
|
||||
$lines[] = 'Anmeldung im Portal'.($free === null ? '' : ($free > 0 ? " – noch {$free} von {$event->capacity} Plätzen frei" : ' – ausgebucht'.($event->waitlist ? ', Warteliste möglich' : ''))).
|
||||
($event->registration_deadline ? ', Anmeldeschluss '.$event->registration_deadline->locale('de')->translatedFormat('j. F Y, H:i').' Uhr' : '').'.';
|
||||
}
|
||||
|
||||
return implode(' ', $lines);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Inhaus\Plugins\Events;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Digest\Digest;
|
||||
use App\Editorial\Editorial;
|
||||
|
|
@ -26,6 +27,7 @@ class EventsPlugin extends Plugin
|
|||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->make(Knowledge::class)->add('events', 'Termine', fn (...$args) => app(EventKnowledge::class)(...$args));
|
||||
// Wochenüberblick: Termine der nächsten zwei Wochen
|
||||
$this->app->make(Digest::class)->add('events', 'Termine', 20, fn (User $user) => Event::query()
|
||||
->upcoming()->visibleTo($user)->where('starts_at', '<=', now()->addDays(14))->limit(8)->get()
|
||||
|
|
|
|||
34
plugins-core/forms/src/FormKnowledge.php
Normal file
34
plugins-core/forms/src/FormKnowledge.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Forms;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use Inhaus\Plugins\Forms\Models\Form;
|
||||
|
||||
/** Wissensquelle für „Frag das Portal“: offene Formulare (z. B. Anträge), die die Person ausfüllen darf */
|
||||
class FormKnowledge
|
||||
{
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
$query = Form::query()->visibleTo($user)->where('is_open', true)
|
||||
->where(fn ($q) => $q->whereNull('closes_at')->orWhere('closes_at', '>', now()));
|
||||
Knowledge::whereAny($query, ['title', 'description'], $terms);
|
||||
|
||||
return $query->orderBy('title')->limit($limit)->get()->map(function (Form $form) {
|
||||
// Feldnamen helfen bei Fragen wie „Wo melde ich einen Schaden am Dienstwagen?“
|
||||
$labels = collect((array) $form->fields)->pluck('data.label')->filter()->take(15)->implode(', ');
|
||||
|
||||
return [
|
||||
'title' => $form->title,
|
||||
'url' => $form->url(),
|
||||
'text' => trim('Online-Formular im Portal. '.Knowledge::plain((string) $form->description).($labels ? "\nFelder: ".$labels : '')),
|
||||
'meta' => 'Formular'.($form->closes_at ? ', offen bis '.$form->closes_at->locale('de')->translatedFormat('j. F Y') : ''),
|
||||
];
|
||||
})->all();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Inhaus\Plugins\Forms;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Editorial\Editorial;
|
||||
use App\Models\User;
|
||||
use App\Pagebuilder\Blocks;
|
||||
|
|
@ -19,6 +20,7 @@ class FormsPlugin extends Plugin
|
|||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->make(Knowledge::class)->add('forms', 'Formulare', fn (...$args) => app(FormKnowledge::class)(...$args));
|
||||
$this->app->make(GlobalSearch::class)->add('forms', 'Formulare', 'clipboard-list', fn (...$args) => app(FormSearch::class)(...$args), sort: 60);
|
||||
|
||||
// Kein eigener Menüpunkt im Portal: Formulare werden in Seiten und Beiträge eingebunden.
|
||||
|
|
|
|||
32
plugins-core/ideen/src/IdeaKnowledge.php
Normal file
32
plugins-core/ideen/src/IdeaKnowledge.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Ideen;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use Inhaus\Plugins\Ideen\Models\Idea;
|
||||
|
||||
/**
|
||||
* Wissensquelle für „Frag das Portal“: Ideen aus der Ideenbox mit ihrem Stand („Gibt es schon
|
||||
* eine Idee zum Jobrad?“). Ausgeblendete Ideen nie, Namen der Einreichenden nie.
|
||||
*/
|
||||
class IdeaKnowledge
|
||||
{
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
$query = Idea::query()->whereNull('hidden_at');
|
||||
Knowledge::whereAny($query, ['title', 'body', 'status_note'], $terms);
|
||||
|
||||
return $query->latest()->limit($limit)->get()->map(fn (Idea $idea) => [
|
||||
'title' => $idea->title,
|
||||
'url' => route('ideas.show', $idea),
|
||||
'text' => 'Idee aus der Ideenbox, Stand: '.(Idea::STATUSES[$idea->status] ?? $idea->status).', unterstützt von '.$idea->supports_count.' Personen.'
|
||||
."\n".$idea->body.($idea->status_note ? "\nRückmeldung der Verantwortlichen: ".$idea->status_note : ''),
|
||||
'meta' => Idea::STATUSES[$idea->status] ?? null,
|
||||
])->all();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Inhaus\Plugins\Ideen;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Digest\Digest;
|
||||
use App\Editorial\Editorial;
|
||||
|
|
@ -16,6 +17,7 @@ class IdeenPlugin extends Plugin
|
|||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->make(Knowledge::class)->add('ideen', 'Ideenbox', fn (...$args) => app(IdeaKnowledge::class)(...$args));
|
||||
$this->app->make(Navigation::class)->add('ideen', 'Ideenbox', '/ideen', active: 'ideas.*', sort: 76, icon: 'lightbulb');
|
||||
$this->app->make(Digest::class)->add('ideen', 'Neue Ideen', 40, fn (User $user, CarbonImmutable $since) => Idea::query()
|
||||
->whereNull('hidden_at')->where('created_at', '>=', $since)->orderByDesc('supports_count')->latest()->limit(5)->get()
|
||||
|
|
|
|||
91
plugins-core/it-service/src/ItKnowledge.php
Normal file
91
plugins-core/it-service/src/ItKnowledge.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\ItService;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use Inhaus\Plugins\ItService\OpenNit\Settings;
|
||||
|
||||
/**
|
||||
* Wissensquelle für „Frag das Portal“: die eigenen IT-Tickets und Geräte der fragenden
|
||||
* Person aus OpenNIT („Wie ist der Stand meines Druckertickets?“, „Welchen Laptop habe ich?“)
|
||||
* sowie der Hinweistext des IT-Service. Nie Daten anderer Personen.
|
||||
*/
|
||||
class ItKnowledge
|
||||
{
|
||||
/** Volltext (Beschreibung und Antworten) nur für so viele Tickets – je Ticket ein Aufruf bei OpenNIT */
|
||||
private const DETAILS = 2;
|
||||
|
||||
/** @var array<string, mixed> Antworten von OpenNIT für diese Anfrage (je Frage wird die Quelle mehrfach gefragt) */
|
||||
private array $memo = [];
|
||||
|
||||
public function __construct(private readonly ItService $it, private readonly Settings $settings) {}
|
||||
|
||||
private function remember(string $key, \Closure $load): mixed
|
||||
{
|
||||
return array_key_exists($key, $this->memo) ? $this->memo[$key] : ($this->memo[$key] = $load());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
if (! $this->it->configured()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$matches = fn (string $text) => collect($terms)->contains(fn (string $term) => Knowledge::occurrences(mb_strtolower($text), $term) > 0);
|
||||
// „mein Ticket“, „Störung“: dann auch offene Tickets ohne passenden Betreff
|
||||
$aboutTickets = collect($terms)->contains(fn (string $term) => in_array($term, ['ticket', 'stör', 'anfrag', 'meld', 'support'], true));
|
||||
$results = [];
|
||||
|
||||
$intro = Knowledge::plain((string) $this->settings->intro());
|
||||
|
||||
if ($intro !== '' && $matches('IT-Service IT Support Ticket '.$intro)) {
|
||||
$results[] = ['title' => 'IT-Service', 'url' => route('it-service.index'), 'text' => $intro, 'meta' => 'Hinweise des IT-Teams'];
|
||||
}
|
||||
|
||||
$tickets = array_values(array_filter($this->remember('tickets.'.$user->id, fn () => $this->it->tickets($user)), fn (array $t) => $matches($t['subject']) || ($aboutTickets && $t['open'])));
|
||||
|
||||
foreach (array_slice($tickets, 0, $limit) as $i => $ticket) {
|
||||
$text = 'Ihr IT-Ticket'.($ticket['number'] ? ' Nr. '.$ticket['number'] : '').': „'.$ticket['subject'].'“. Stand: '.$ticket['status_label'].'.'
|
||||
.($ticket['created_at'] ? ' Erstellt am '.$ticket['created_at'].'.' : '').($ticket['updated_at'] ? ' Zuletzt bearbeitet am '.$ticket['updated_at'].'.' : '');
|
||||
|
||||
if ($i < self::DETAILS) {
|
||||
$detail = $this->remember('ticket.'.$user->id.'.'.$ticket['id'], fn () => $this->it->ticket($user, $ticket['id']));
|
||||
$text .= "\n".Knowledge::plain((string) ($detail['description'] ?? ''));
|
||||
|
||||
foreach (array_slice($detail['replies'] ?? [], -3) as $reply) {
|
||||
$text .= "\n".($reply['from_staff'] ? 'Antwort des IT-Teams' : 'Ihre Nachricht').': '.Knowledge::plain((string) $reply['message']);
|
||||
}
|
||||
}
|
||||
|
||||
$results[] = ['title' => 'Mein Ticket: '.$ticket['subject'], 'url' => route('it-service.tickets.show', $ticket['id']), 'text' => $text, 'meta' => $ticket['status_label']];
|
||||
}
|
||||
|
||||
foreach ($this->remember('assets.'.$user->id, fn () => $this->it->assets($user)) as $asset) {
|
||||
$description = collect([$asset['type'], $asset['manufacturer'], $asset['model']])->filter()->implode(' ');
|
||||
|
||||
if (! $matches($asset['name'].' '.$description.' gerät geräte laptop computer')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$results[] = [
|
||||
'title' => 'Mein Gerät: '.$asset['name'],
|
||||
'url' => route('it-service.index'),
|
||||
'text' => implode(' ', array_filter([
|
||||
'Ihnen zugeordnetes Gerät: '.$asset['name'].($description ? ' ('.$description.')' : '').'.',
|
||||
$asset['inventory'] ? 'Inventarnummer '.$asset['inventory'].'.' : null,
|
||||
$asset['serial'] ? 'Seriennummer '.$asset['serial'].'.' : null,
|
||||
$asset['location'] ? 'Standort '.$asset['location'].'.' : null,
|
||||
$asset['warranty_end'] ? 'Garantie bis '.$asset['warranty_end'].'.' : null,
|
||||
])),
|
||||
'meta' => 'Meine IT',
|
||||
];
|
||||
}
|
||||
|
||||
return array_slice($results, 0, $limit);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Inhaus\Plugins\ItService;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Models\User;
|
||||
use App\Plugins\Hooks;
|
||||
|
|
@ -18,6 +19,9 @@ class ItServicePlugin extends Plugin
|
|||
{
|
||||
public function register(): void
|
||||
{
|
||||
// Eine Instanz je Anfrage: merkt sich die Antworten von OpenNIT
|
||||
$this->app->scoped(ItKnowledge::class);
|
||||
$this->app->make(Knowledge::class)->add('it-service', 'Meine IT', fn (...$args) => app(ItKnowledge::class)(...$args));
|
||||
$this->app->singleton(Settings::class);
|
||||
$this->app->make(Abilities::class)->define('it-service.manage', 'IT-Service (OpenNIT) einrichten', 'IT-Service');
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class PageKnowledge
|
|||
$text = $this->content->plainText($this->content->render($page->content, $user, ['page_id' => $page->id]));
|
||||
$haystack = mb_strtolower($page->title.' '.$text);
|
||||
|
||||
if (! collect($terms)->contains(fn (string $term) => str_contains($haystack, $term))) {
|
||||
if (! collect($terms)->contains(fn (string $term) => Knowledge::occurrences($haystack, $term) > 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
37
plugins-core/stellen/src/JobKnowledge.php
Normal file
37
plugins-core/stellen/src/JobKnowledge.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Stellen;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use Inhaus\Plugins\Stellen\Models\JobPosting;
|
||||
|
||||
/** Wissensquelle für „Frag das Portal“: offene interne Stellenausschreibungen */
|
||||
class JobKnowledge
|
||||
{
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
$query = JobPosting::query()->open()->with('contact');
|
||||
Knowledge::whereAny($query, ['title', 'department', 'location', 'description'], $terms);
|
||||
|
||||
return $query->latest('published_at')->limit($limit)->get()->map(fn (JobPosting $job) => [
|
||||
'title' => $job->title,
|
||||
'url' => route('jobs.show', $job),
|
||||
'text' => implode(' ', array_filter([
|
||||
'Offene Stelle: '.$job->title.'.',
|
||||
$job->department ? 'Bereich: '.$job->department.'.' : null,
|
||||
$job->location ? 'Standort: '.$job->location.'.' : null,
|
||||
$job->summary() ? 'Umfang: '.$job->summary().'.' : null,
|
||||
$job->pay_grade ? 'Vergütung: '.$job->pay_grade.'.' : null,
|
||||
$job->start ? 'Beginn: '.$job->start.'.' : null,
|
||||
$job->deadline ? 'Bewerbungsfrist: '.$job->deadline->locale('de')->translatedFormat('j. F Y').'.' : null,
|
||||
$job->contact ? 'Ansprechperson: '.$job->contact->name.'.' : null,
|
||||
]))."\n".Knowledge::plain((string) $job->description),
|
||||
'meta' => collect([$job->department, $job->location])->filter()->implode(', ') ?: null,
|
||||
])->all();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Inhaus\Plugins\Stellen;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Digest\Digest;
|
||||
use App\Editorial\Editorial;
|
||||
use App\Media\ImagePaths;
|
||||
|
|
@ -20,6 +21,7 @@ class StellenPlugin extends Plugin
|
|||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->make(Knowledge::class)->add('stellen', 'Stellenangebote', fn (...$args) => app(JobKnowledge::class)(...$args));
|
||||
$this->app->make(Navigation::class)->add('stellen', 'Stellen', '/stellen', active: 'jobs.*', sort: 72, icon: 'briefcase');
|
||||
|
||||
$this->app->make(Digest::class)->add('stellen', 'Neue interne Stellen', 50, fn (User $user, CarbonImmutable $since) => JobPosting::query()
|
||||
|
|
|
|||
29
plugins-core/umfragen/src/PollKnowledge.php
Normal file
29
plugins-core/umfragen/src/PollKnowledge.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Umfragen;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use Inhaus\Plugins\Umfragen\Models\Poll;
|
||||
|
||||
/** Wissensquelle für „Frag das Portal“: veröffentlichte Umfragen, die die Person sieht (ohne Antworten) */
|
||||
class PollKnowledge
|
||||
{
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
$query = Poll::query()->published()->visibleTo($user);
|
||||
Knowledge::whereAny($query, ['title', 'description'], $terms);
|
||||
|
||||
return $query->latest('published_at')->limit($limit)->get()->map(fn (Poll $poll) => [
|
||||
'title' => $poll->title,
|
||||
'url' => route('polls.show', $poll),
|
||||
'text' => 'Umfrage im Portal, '.($poll->isOpen() ? 'läuft noch'.($poll->closes_at ? ' bis '.$poll->closes_at->locale('de')->translatedFormat('j. F Y') : '') : 'beendet').'. '
|
||||
.Knowledge::plain((string) $poll->description)."\nFragen: ".collect((array) $poll->questions)->pluck('label')->filter()->implode(' / '),
|
||||
'meta' => $poll->isOpen() ? 'läuft' : 'beendet',
|
||||
])->all();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Inhaus\Plugins\Umfragen;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Digest\Digest;
|
||||
use App\Editorial\Editorial;
|
||||
|
|
@ -22,6 +23,7 @@ class UmfragenPlugin extends Plugin
|
|||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->make(Knowledge::class)->add('umfragen', 'Umfragen', fn (...$args) => app(PollKnowledge::class)(...$args));
|
||||
$this->app->make(Navigation::class)->add('umfragen', 'Umfragen', '/umfragen', active: 'polls.*', sort: 74, icon: 'vote');
|
||||
$this->app->make(Digest::class)->add('umfragen', 'Ihre Meinung ist gefragt', 30, fn (User $user) => Poll::query()
|
||||
->open()->visibleTo($user)->latest('published_at')->limit(10)->get()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue