redesign user data api
This commit is contained in:
parent
f132049948
commit
44361e614d
17 changed files with 80 additions and 52 deletions
|
|
@ -1,9 +1,24 @@
|
|||
<?php
|
||||
|
||||
return function ($page) {
|
||||
return function ($page, $kirby) {
|
||||
$data = $page->toArray();
|
||||
$data['template'] = (string) $page->template();
|
||||
|
||||
$userData = [
|
||||
"role" => $kirby->user()->role(),
|
||||
"uuid" => $kirby->user()->uuid(),
|
||||
"notifications" => Yaml::decode($kirby->user()->notifications()->value()),
|
||||
];
|
||||
|
||||
if ($kirby->user()->role() == 'client') {
|
||||
$userData['client'] = [
|
||||
"name" => $kirby->user()->client()->toPage()->title(),
|
||||
"uuid" => $kirby->user()->client()->toPage()->uuid()
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'genericData' => $data,
|
||||
'userData' => $userData
|
||||
];
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue