front > account : start
This commit is contained in:
parent
d15d4898c6
commit
443369ee23
5 changed files with 83 additions and 0 deletions
|
|
@ -7,6 +7,8 @@ return function ($page, $kirby, $site) {
|
|||
|
||||
if ($kirby->user()) {
|
||||
$userData = [
|
||||
"name" => (string) $kirby->user()->name()->or(null),
|
||||
"email" => (string) $kirby->user()->email(),
|
||||
"role" => (string) $kirby->user()->role(),
|
||||
"uuid" => (string) $kirby->user()->uuid()
|
||||
];
|
||||
|
|
@ -17,6 +19,16 @@ return function ($page, $kirby, $site) {
|
|||
"uuid" => (string) $kirby->user()->client()->toPage()->uuid()
|
||||
];
|
||||
}
|
||||
|
||||
if ($kirby->user()->projects()->exists() && $kirby->user()->projects()->isNotEmpty()) {
|
||||
$userData['projects'] = $kirby->user()->projects()->toPages()->map(function ($project) {
|
||||
return [
|
||||
"title" => (string) $project->title(),
|
||||
"uri" => (string) $project->uri(),
|
||||
"step" => (string) $project->getStepLabel(),
|
||||
];
|
||||
})->data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
6
public/site/templates/account.json.php
Normal file
6
public/site/templates/account.json.php
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
echo json_encode([
|
||||
"page" => $genericData,
|
||||
"user" => $userData
|
||||
]);
|
||||
1
public/site/templates/account.php
Normal file
1
public/site/templates/account.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
<?php snippet('generic-template') ?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue