Globale Live-Suche, Kontaktkarten-Personensuche, neue Beitragsansicht, Termine mit Seitenleiste, Demo-Inhalte, Plugin-Upload-Fix
Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m24s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m26s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m41s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m46s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m31s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m18s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m14s
Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m24s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m26s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m41s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m46s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m31s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m18s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m14s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9b06e65802
commit
b276e1c6d0
211 changed files with 3580 additions and 1072 deletions
|
|
@ -42,6 +42,6 @@ class CoreWidgets
|
|||
|
||||
$widgets->add('core.people-search', 'core::PeopleSearch', 'aside', sort: 60, props: fn () => [
|
||||
'count' => User::query()->active()->count(),
|
||||
], label: 'Personen finden', mobileSort: 80);
|
||||
], label: 'Kolleg:innen finden (Personensuche)', mobileSort: 80);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,16 +138,30 @@ class Widgets
|
|||
}
|
||||
|
||||
/**
|
||||
* Seitenleiste der Startseite für andere Seiten (z. B. Termine).
|
||||
*
|
||||
* @param list<string> $except Kacheln, die auf der Seite doppelt wären
|
||||
* @return list<array{key: string, component: string, area: string, mobileSort: int, props: array<string, mixed>}>
|
||||
*/
|
||||
public function resolve(User $user, Request $request): array
|
||||
public function sidebar(User $user, Request $request, array $except = []): array
|
||||
{
|
||||
$keep = fn (array $w) => $w['area'] === 'aside' && ! in_array($w['key'], $except, true);
|
||||
|
||||
return array_values(array_filter($this->resolve($user, $request, $keep), $keep));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param (callable(array{key: string, area: string}): bool)|null $only nur diese Kacheln berechnen
|
||||
* @return list<array{key: string, component: string, area: string, mobileSort: int, props: array<string, mixed>}>
|
||||
*/
|
||||
public function resolve(User $user, Request $request, ?callable $only = null): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$layout = $this->layout();
|
||||
|
||||
foreach ($this->candidates($user) as $key => $widget) {
|
||||
if (($layout[$key]['visible'] ?? true) === false) {
|
||||
if (($layout[$key]['visible'] ?? true) === false || ($only && ! $only(['key' => $key, 'area' => $widget['area']]))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace App\Filament\Pages;
|
|||
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Filament\Resources\DashboardTiles\DashboardTileResource;
|
||||
use App\Support\ContactCards;
|
||||
use App\Support\Settings;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
|
|
@ -57,7 +58,10 @@ class DashboardSettings extends Page
|
|||
|
||||
public function mount(Widgets $widgets): void
|
||||
{
|
||||
$this->form->fill(collect(self::AREAS)->mapWithKeys(fn ($info, $area) => [$area => $widgets->forAdmin($area)])->all());
|
||||
$this->form->fill([
|
||||
...collect(self::AREAS)->mapWithKeys(fn ($info, $area) => [$area => $widgets->forAdmin($area)])->all(),
|
||||
'people_fields' => (array) app(Settings::class)->get(ContactCards::PEOPLE_SEARCH_FIELDS, ContactCards::DEFAULT_PEOPLE_SEARCH_FIELDS),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -80,8 +84,8 @@ class DashboardSettings extends Page
|
|||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->statePath('data')->components(
|
||||
collect(self::AREAS)->map(fn ($info, $area) => Section::make($info[0])
|
||||
return $schema->statePath('data')->components([
|
||||
...collect(self::AREAS)->map(fn ($info, $area) => Section::make($info[0])
|
||||
->description($info[1] ?: null)
|
||||
->visible(fn () => app(Widgets::class)->forAdmin($area) !== [])
|
||||
->schema([
|
||||
|
|
@ -104,8 +108,16 @@ class DashboardSettings extends Page
|
|||
->visible(fn (Get $get) => count(self::areasOf($get('key'))) > 1)
|
||||
->helperText('Wird nach dem Speichern in den gewählten Bereich verschoben.'),
|
||||
]),
|
||||
]))->values()->all()
|
||||
);
|
||||
]))->values()->all(),
|
||||
Section::make('Kachel „Kolleg:innen finden“')
|
||||
->description('Welche Angaben auf den Kontaktkarten der Live-Suche erscheinen – in dieser Reihenfolge. Name, Foto, Funktion und Abteilung stehen immer oben.')
|
||||
->schema([
|
||||
Select::make('people_fields')
|
||||
->hiddenLabel()
|
||||
->multiple()
|
||||
->options(fn () => app(ContactCards::class)->options()),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function save(Settings $settings): void
|
||||
|
|
@ -123,6 +135,7 @@ class DashboardSettings extends Page
|
|||
}
|
||||
|
||||
$settings->set('dashboard.layout', $layout);
|
||||
$settings->set(ContactCards::PEOPLE_SEARCH_FIELDS, array_values(array_intersect((array) ($this->data['people_fields'] ?? []), array_keys(app(ContactCards::class)->options()))));
|
||||
|
||||
// Verschobene Kacheln im Formular in ihren neuen Bereich umsortieren
|
||||
$this->mount(app(Widgets::class));
|
||||
|
|
|
|||
114
app/Filament/Pages/DemoContent.php
Normal file
114
app/Filament/Pages/DemoContent.php
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Support\Audit;
|
||||
use App\Support\Demo\DemoContent as Demo;
|
||||
use BackedEnum;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* Demo-Inhalte für Test- und Vorführinstallationen per Klick anlegen und
|
||||
* wieder entfernen – ohne Shell-Zugang auf dem Server.
|
||||
*/
|
||||
class DemoContent extends Page
|
||||
{
|
||||
protected string $view = 'filament.pages.demo-content';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedSparkles;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'System';
|
||||
|
||||
protected static ?int $navigationSort = 90;
|
||||
|
||||
protected static ?string $navigationLabel = 'Demo-Inhalte';
|
||||
|
||||
protected static ?string $title = 'Demo-Inhalte';
|
||||
|
||||
protected static ?string $slug = 'demo-inhalte';
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('updates.manage') ?? false;
|
||||
}
|
||||
|
||||
public function install(Demo $demo): void
|
||||
{
|
||||
abort_unless(static::canAccess(), 403);
|
||||
@set_time_limit(300);
|
||||
|
||||
try {
|
||||
$result = $demo->install(auth()->user());
|
||||
} catch (Throwable $e) {
|
||||
report($e);
|
||||
Notification::make()->danger()->title('Demo-Inhalte nicht angelegt')->body($e->getMessage())->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Audit::log('demo.installed', ['counts' => $result['counts']]);
|
||||
|
||||
Notification::make()->success()->title('Demo-Inhalte angelegt')
|
||||
->body(collect($result['counts'])->map(fn ($count, $label) => "{$count} {$label}")->implode(', '))
|
||||
->send();
|
||||
|
||||
$this->warn($result['warnings'], 'Einige Bereiche konnten nicht angelegt werden');
|
||||
}
|
||||
|
||||
public function remove(Demo $demo): void
|
||||
{
|
||||
abort_unless(static::canAccess(), 403);
|
||||
@set_time_limit(300);
|
||||
|
||||
try {
|
||||
$result = $demo->remove();
|
||||
} catch (Throwable $e) {
|
||||
report($e);
|
||||
Notification::make()->danger()->title('Demo-Inhalte nicht entfernt')->body($e->getMessage())->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Audit::log('demo.removed', ['records' => $result['records'], 'files' => $result['files']]);
|
||||
|
||||
Notification::make()->success()->title('Demo-Inhalte entfernt')
|
||||
->body("{$result['records']} Einträge und {$result['files']} Dateien gelöscht.")
|
||||
->send();
|
||||
|
||||
$this->warn($result['warnings'], 'Nicht alles konnte entfernt werden');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $warnings
|
||||
*/
|
||||
private function warn(array $warnings, string $title): void
|
||||
{
|
||||
if ($warnings === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
Notification::make()->warning()->title($title)
|
||||
->body(Str::limit(implode("\n", $warnings), 1000))
|
||||
->persistent()
|
||||
->send();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function getViewData(): array
|
||||
{
|
||||
$demo = app(Demo::class);
|
||||
|
||||
return [
|
||||
'installed' => $demo->isInstalled(),
|
||||
'installedAt' => $demo->installedAt(),
|
||||
'counts' => $demo->counts(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ class Plugins extends Page
|
|||
$this->run(fn () => $plugins->delete($slug, $removeData), 'Plugin gelöscht', $removeData ? 'Das Plugin und seine Daten wurden entfernt.' : 'Die Daten des Plugins sind noch in der Datenbank.');
|
||||
}
|
||||
|
||||
public function upload(PluginInstaller $installer): void
|
||||
public function installArchive(PluginInstaller $installer): void
|
||||
{
|
||||
$this->validate(['archive' => ['required', 'file', 'mimes:zip', 'max:51200']], attributes: ['archive' => 'ZIP-Archiv']);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Http\Resources\PersonResource;
|
||||
use App\Models\User;
|
||||
use App\Search\GlobalSearch;
|
||||
use App\Support\ContactCards;
|
||||
use App\Support\ProfileFields;
|
||||
use App\Support\Settings;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
@ -80,6 +83,28 @@ class PeopleController extends Controller
|
|||
return response()->json(['people' => PersonResource::collection($people)->resolve()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Live-Suche der Kachel „Personen finden“: Kontaktkarten mit den im Admin gewählten Feldern.
|
||||
*/
|
||||
public function cards(Request $request, ContactCards $cards, Settings $settings): JsonResponse
|
||||
{
|
||||
$search = trim((string) ($request->validate(['q' => ['nullable', 'string', 'max:100']])['q'] ?? ''));
|
||||
|
||||
if (mb_strlen($search) < 2) {
|
||||
return response()->json(['people' => [], 'total' => 0]);
|
||||
}
|
||||
|
||||
$query = User::query()->active();
|
||||
|
||||
GlobalSearch::whereTerms($query, ['name', 'email', 'job_title', 'department', 'location', 'phone', 'mobile'], $search);
|
||||
|
||||
$total = (clone $query)->count();
|
||||
$people = $query->orderBy('last_name')->orderBy('first_name')->orderBy('name')->limit(5)->get();
|
||||
$fields = (array) $settings->get(ContactCards::PEOPLE_SEARCH_FIELDS, ContactCards::DEFAULT_PEOPLE_SEARCH_FIELDS);
|
||||
|
||||
return response()->json(['people' => $cards->cards($people, $request->user(), $fields), 'total' => $total]);
|
||||
}
|
||||
|
||||
public function show(User $user): Response
|
||||
{
|
||||
abort_unless($user->is_active, 404);
|
||||
|
|
|
|||
31
app/Http/Controllers/SearchController.php
Normal file
31
app/Http/Controllers/SearchController.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Search\GlobalSearch;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class SearchController extends Controller
|
||||
{
|
||||
public function index(Request $request, GlobalSearch $search): Response
|
||||
{
|
||||
$query = trim((string) $request->validate(['q' => ['nullable', 'string', 'max:100']])['q'] ?? '');
|
||||
|
||||
return Inertia::render('Search/Index', [
|
||||
'query' => $query,
|
||||
'groups' => $search->run($request->user(), $query, 20),
|
||||
'minLength' => GlobalSearch::MIN_LENGTH,
|
||||
]);
|
||||
}
|
||||
|
||||
/** Vorschläge für das Suchfeld in der Kopfzeile */
|
||||
public function live(Request $request, GlobalSearch $search): JsonResponse
|
||||
{
|
||||
$query = trim((string) $request->validate(['q' => ['nullable', 'string', 'max:100']])['q'] ?? '');
|
||||
|
||||
return response()->json(['query' => $query, 'groups' => $search->run($request->user(), $query, 4)]);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ use App\Identity\IdentityDrivers;
|
|||
use App\Models\IdentityProvider;
|
||||
use App\Models\User;
|
||||
use App\Pagebuilder\Blocks;
|
||||
use App\Search\GlobalSearch;
|
||||
use App\Support\Abilities;
|
||||
use App\Support\Avatars;
|
||||
use App\Support\BackgroundTasks;
|
||||
|
|
@ -54,6 +55,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
$this->app->singleton(ThemeCompiler::class);
|
||||
$this->app->singleton(Avatars::class);
|
||||
$this->app->singleton(QuickLinks::class);
|
||||
$this->app->singleton(GlobalSearch::class);
|
||||
$this->app->singleton(LicenseStore::class);
|
||||
$this->app->singleton(Permissions::class);
|
||||
$this->app->singleton(ProfileFields::class);
|
||||
|
|
|
|||
129
app/Search/GlobalSearch.php
Normal file
129
app/Search/GlobalSearch.php
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
namespace App\Search;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Globale Suche (Kopfzeile und /suche). Kern und Plugins melden Quellen an;
|
||||
* jede Quelle liefert nur, was die Person sehen darf. Personen sind bewusst
|
||||
* nicht dabei – dafür gibt es das Verzeichnis und die Kachel „Personen finden“.
|
||||
*
|
||||
* Treffer: ['title' => …, 'url' => …, 'excerpt' => ?, 'meta' => ?, 'image' => ?, 'external' => ?bool]
|
||||
*/
|
||||
class GlobalSearch
|
||||
{
|
||||
public const MIN_LENGTH = 2;
|
||||
|
||||
/** @var array<string, array{label: string, icon: string, sort: int, search: callable}> */
|
||||
private array $sources = [];
|
||||
|
||||
/**
|
||||
* @param string $icon Lucide-Name, z. B. „newspaper“
|
||||
* @param callable(User, string, int): list<array<string, mixed>> $search
|
||||
*/
|
||||
public function add(string $key, string $label, string $icon, callable $search, int $sort = 50): void
|
||||
{
|
||||
$this->sources[$key] = compact('label', 'icon', 'sort', 'search');
|
||||
}
|
||||
|
||||
public function remove(string $key): void
|
||||
{
|
||||
unset($this->sources[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{key: string, label: string, icon: string, items: list<array<string, mixed>>}>
|
||||
*/
|
||||
public function run(User $user, string $query, int $limit): array
|
||||
{
|
||||
$query = trim($query);
|
||||
|
||||
if (mb_strlen($query) < self::MIN_LENGTH) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$groups = [];
|
||||
|
||||
foreach (collect($this->sources)->sortBy('sort') as $key => $source) {
|
||||
try {
|
||||
$items = array_slice(array_values(($source['search'])($user, $query, $limit)), 0, $limit);
|
||||
} catch (Throwable $e) {
|
||||
// Eine fehlerhafte Quelle darf die Suche nicht lahmlegen.
|
||||
Log::error("Suchquelle {$key} fehlgeschlagen: ".$e->getMessage(), ['exception' => $e]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($items !== []) {
|
||||
$groups[] = ['key' => $key, 'label' => $source['label'], 'icon' => $source['icon'], 'items' => $items];
|
||||
}
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Suchbegriffe (alle müssen vorkommen).
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public static function terms(string $query): array
|
||||
{
|
||||
return array_values(array_filter(preg_split('/\s+/u', trim($query)) ?: [], fn ($t) => $t !== ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Jeder Begriff muss in mindestens einer der Spalten vorkommen.
|
||||
*
|
||||
* @param Builder<Model> $query
|
||||
* @param list<string> $columns
|
||||
*/
|
||||
public static function whereTerms(Builder $query, array $columns, string $search): void
|
||||
{
|
||||
foreach (self::terms($search) as $term) {
|
||||
$like = '%'.str_replace(['\\', '%', '_'], ['\\\\', '\\%', '\\_'], $term).'%';
|
||||
$query->where(function (Builder $q) use ($columns, $like) {
|
||||
foreach ($columns as $column) {
|
||||
$q->orWhere($column, 'like', $like);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Textausschnitt rund um den ersten Treffer (ohne HTML).
|
||||
*/
|
||||
public static function excerpt(?string $text, string $query, int $length = 160): ?string
|
||||
{
|
||||
$plain = trim((string) preg_replace('/\s+/u', ' ', html_entity_decode(strip_tags(str_replace('>', '> ', (string) $text)), ENT_QUOTES | ENT_HTML5)));
|
||||
|
||||
if ($plain === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$position = null;
|
||||
|
||||
foreach (self::terms($query) as $term) {
|
||||
$found = mb_stripos($plain, $term);
|
||||
|
||||
if ($found !== false && ($position === null || $found < $position)) {
|
||||
$position = $found;
|
||||
}
|
||||
}
|
||||
|
||||
if ($position === null || $position < $length / 3) {
|
||||
return Str::limit($plain, $length);
|
||||
}
|
||||
|
||||
$start = max(0, $position - (int) ($length / 3));
|
||||
$snippet = mb_substr($plain, $start, $length);
|
||||
|
||||
return '… '.trim($snippet).(mb_strlen($plain) > $start + $length ? ' …' : '');
|
||||
}
|
||||
}
|
||||
79
app/Support/ContactCards.php
Normal file
79
app/Support/ContactCards.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Kontaktkarten: Person mit ausgewählten Profilfeldern (Kern- und eigene Felder).
|
||||
* Genutzt von der Personensuche auf der Startseite und von Plugins (z. B. QM-Ansprechpartner).
|
||||
*/
|
||||
class ContactCards
|
||||
{
|
||||
/** Kernfelder des Profils, die auf Karten erscheinen können. */
|
||||
public const CORE_FIELDS = [
|
||||
'job_title' => 'Funktion',
|
||||
'department' => 'Abteilung',
|
||||
'location' => 'Standort',
|
||||
'phone' => 'Telefon',
|
||||
'mobile' => 'Mobil',
|
||||
'email' => 'E-Mail-Adresse',
|
||||
];
|
||||
|
||||
/** Felder der Personensuche auf der Startseite (Einstellung) */
|
||||
public const PEOPLE_SEARCH_FIELDS = 'people.search_fields';
|
||||
|
||||
public const DEFAULT_PEOPLE_SEARCH_FIELDS = ['email', 'phone', 'mobile', 'location'];
|
||||
|
||||
public function __construct(private readonly ProfileFields $profileFields) {}
|
||||
|
||||
/**
|
||||
* @return array<string, string> auswählbare Felder für Einstellungen
|
||||
*/
|
||||
public function options(): array
|
||||
{
|
||||
return self::CORE_FIELDS + collect($this->profileFields->options())->mapWithKeys(fn ($label, $key) => ['custom.'.$key => $label.' (Profilfeld)'])->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iterable<User> $people
|
||||
* @param list<string> $fields Schlüssel aus options()
|
||||
* @return list<array{id: int, name: string, initials: string, avatar_url: ?string, subtitle: ?string, fields: list<array{key: string, label: string, value: string, type: string}>}>
|
||||
*/
|
||||
public function cards(iterable $people, ?User $viewer, array $fields): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($people as $person) {
|
||||
if (! $person->is_active) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = [];
|
||||
$custom = collect($this->profileFields->visibleValues($person, $viewer))->keyBy('key');
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if (isset(self::CORE_FIELDS[$field])) {
|
||||
$value = $person->{$field};
|
||||
|
||||
if (filled($value)) {
|
||||
$values[] = ['key' => $field, 'label' => self::CORE_FIELDS[$field], 'value' => (string) $value, 'type' => in_array($field, ['phone', 'mobile'], true) ? 'phone' : ($field === 'email' ? 'email' : 'text')];
|
||||
}
|
||||
} elseif (str_starts_with($field, 'custom.') && ($item = $custom->get(substr($field, 7)))) {
|
||||
$values[] = ['key' => $field, 'label' => $item['label'], 'value' => (string) $item['value'], 'type' => $item['type'] ?? 'text'];
|
||||
}
|
||||
}
|
||||
|
||||
$result[] = [
|
||||
'id' => $person->id,
|
||||
'name' => $person->name,
|
||||
'initials' => $person->initials,
|
||||
'avatar_url' => $person->avatarUrl(160),
|
||||
'subtitle' => collect([$person->job_title, $person->department])->filter()->implode(' · ') ?: null,
|
||||
'fields' => $values,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
1094
app/Support/Demo/DemoContent.php
Normal file
1094
app/Support/Demo/DemoContent.php
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -9,5 +9,5 @@ namespace App;
|
|||
*/
|
||||
final class Version
|
||||
{
|
||||
public const VERSION = '0.12.3';
|
||||
public const VERSION = '0.13.0';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue