project creation request notification working
This commit is contained in:
parent
c750001a2c
commit
c75c5e1d8a
7 changed files with 93 additions and 13 deletions
|
|
@ -7,6 +7,8 @@ return [
|
|||
$json = file_get_contents('php://input');
|
||||
$data = json_decode($json);
|
||||
|
||||
$user = kirby()->user();
|
||||
|
||||
$client = kirby()->user()->client()->toPage()->uuid();
|
||||
|
||||
$projectData = [
|
||||
|
|
@ -23,7 +25,24 @@ return [
|
|||
|
||||
$projects = page("projects");
|
||||
try {
|
||||
$projects->createChild($projectData);
|
||||
$newProject = $projects->createChild($projectData);
|
||||
|
||||
$date = new DateTime();
|
||||
$formattedDate = $date->format(DateTime::ISO8601);
|
||||
|
||||
$notificationData = [
|
||||
"location" => [
|
||||
"page" => $newProject
|
||||
],
|
||||
"date" => (string) $formattedDate,
|
||||
"text" => nl2br(esc($data->details)),
|
||||
"author" => $user,
|
||||
"id" => Str::uuid(),
|
||||
"type" => "project-request",
|
||||
];
|
||||
|
||||
$newProject->createNotification($notificationData);
|
||||
|
||||
return [
|
||||
"status" => "success",
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue