47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
use App\Repositories\UserRepository;
|
|
use App\Resources\UserResource;
|
|
|
|
class GlobalDataProvider {
|
|
private ?User $user;
|
|
|
|
public function __invoke() {
|
|
$this->user = auth()->user();
|
|
|
|
return response()->json([
|
|
'user' => null !== $this->user ? new UserResource($this->user)->toArray(request()) : [],
|
|
'navbar' => $this->generateNavbar(),
|
|
'tenant' => app('tenant'),
|
|
'availableLocalGroups' => Tenant::where(['is_active_local_group' => true])->get(),
|
|
]);
|
|
}
|
|
|
|
private function generateNavbar() : array {
|
|
$navigation = [
|
|
'personal' => [],
|
|
'common' => [],
|
|
'costunits' => [],
|
|
'events' => [],
|
|
];
|
|
|
|
$navigation['personal'][] = ['url' => '/', 'display' => 'Home'];
|
|
if (null !== $this->user) {
|
|
$navigation['personal'][] = ['url' => '/personal-data', 'display' => 'Meine Daten'];
|
|
$navigation['personal'][] = ['url' => '/messages', 'display' => 'Meine Nachrichten'];
|
|
|
|
$navigation['costunits'][] = ['url' => '/cost-unit/create', 'display' => 'Neue laufende Tätigkeit'];
|
|
|
|
}
|
|
|
|
$navigation['common'][] = ['url' => '/capture-invoice', 'display' => 'Neue Abrechnung'];
|
|
$navigation['common'][] = ['url' => '/available-events', 'display' => 'Verfügbare Veranstaltungen'];
|
|
|
|
return $navigation;
|
|
}
|
|
}
|