Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m7s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m30s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 8m6s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 8m21s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 17m13s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 17m12s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 9m52s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 9m29s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 47s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m23s
Untertitel, Logo, Kategorie, Rollen und Anheften je Eintrag; Knopf „Anwendungen“ in der Kopfzeile mit allen sichtbaren Einträgen. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
52 lines
2.4 KiB
PHP
52 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Dashboard;
|
|
|
|
use App\Http\Resources\PersonResource;
|
|
use App\Models\User;
|
|
use App\Plugins\Hooks;
|
|
use App\Support\QuickLinks;
|
|
|
|
/**
|
|
* Kacheln des Kerns. Plugins ergänzen weitere über App\Dashboard\Widgets.
|
|
*/
|
|
class CoreWidgets
|
|
{
|
|
public static function register(Widgets $widgets): void
|
|
{
|
|
$widgets->add('core.greeting', 'core::Greeting', 'aside', sort: 0, props: fn (User $user) => [
|
|
'profile' => [
|
|
'job_title' => $user->job_title,
|
|
'department' => $user->department,
|
|
'location' => $user->location,
|
|
'avatar_url' => $user->avatarUrl(256),
|
|
],
|
|
// Zusätzliche Knöpfe aus Plugins: Hooks::filter('greeting.actions', fn ($actions, User $user) => [...$actions, ['label' => …, 'href' => …, 'icon' => …]])
|
|
'actions' => array_values(array_filter((array) Hooks::apply('greeting.actions', [], $user), fn ($action) => is_array($action) && isset($action['label'], $action['href']))),
|
|
], label: 'Begrüßung mit Profil', mobileSort: 0);
|
|
|
|
$widgets->add('core.quick-links', 'core::QuickLinks', 'main', sort: 10, props: function (User $user) {
|
|
$links = app(QuickLinks::class)->forUser($user);
|
|
|
|
return $links === [] ? null : ['links' => QuickLinks::pinned($links), 'total' => count($links)];
|
|
}, label: 'Schnellzugriffe', mobileSort: 40, areas: ['main', 'aside']);
|
|
|
|
$widgets->add('core.new-colleagues', 'core::NewColleagues', 'main', sort: 90, props: function (User $user) {
|
|
$people = User::query()
|
|
->active()
|
|
->whereKeyNot($user->getKey())
|
|
->where('created_at', '>=', now()->subDays(90))
|
|
->latest()
|
|
->limit(6)
|
|
->get();
|
|
|
|
return $people->isEmpty() ? null : ['people' => PersonResource::collection($people)->resolve()];
|
|
}, label: 'Neue Kolleginnen und Kollegen', mobileSort: 60);
|
|
|
|
$widgets->add('core.profile-incomplete', 'core::ProfileIncomplete', 'aside', sort: 50, props: fn (User $user) => $user->avatar_path && $user->job_title ? null : [], label: 'Hinweis „Profil vervollständigen“', mobileSort: 70);
|
|
|
|
$widgets->add('core.people-search', 'core::PeopleSearch', 'aside', sort: 60, props: fn () => [
|
|
'count' => User::query()->active()->count(),
|
|
], label: 'Kolleg:innen finden (Personensuche)', mobileSort: 80);
|
|
}
|
|
}
|