project creation request form working
This commit is contained in:
parent
6c84f723f7
commit
c750001a2c
14 changed files with 194 additions and 89 deletions
37
public/site/config/routes/request-project-creation.php
Normal file
37
public/site/config/routes/request-project-creation.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'pattern' => 'request-project-creation.json',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
$json = file_get_contents('php://input');
|
||||
$data = json_decode($json);
|
||||
|
||||
$client = kirby()->user()->client()->toPage()->uuid();
|
||||
|
||||
$projectData = [
|
||||
"slug" => esc(Str::slug($data->title)),
|
||||
"template" => "project",
|
||||
"content" => [
|
||||
"title" => esc($data->title),
|
||||
"requestDetails" => esc("Demande de " . kirby()->user()->name() . " (" . kirby()->user()->email() . ") : \n\n" . $data->details),
|
||||
"client" => [$client],
|
||||
"isClientRequest" => "true",
|
||||
"isDTLEnabled" => esc($data->isDTLEnabled)
|
||||
]
|
||||
];
|
||||
|
||||
$projects = page("projects");
|
||||
try {
|
||||
$projects->createChild($projectData);
|
||||
return [
|
||||
"status" => "success",
|
||||
];
|
||||
} catch (\Throwable $th) {
|
||||
return [
|
||||
"status" => "error",
|
||||
"message" => $th->getMessage() . " in " . $th->getFile() . " line " . $th->getLine()
|
||||
];
|
||||
}
|
||||
}
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue