create comment classes
This commit is contained in:
parent
cd1f065962
commit
f5ffe312e2
8 changed files with 246 additions and 63 deletions
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use adrienpayet\comments\Comment;
|
||||
|
||||
return [
|
||||
'pattern' => '(:all)create-comment.json',
|
||||
'method' => 'POST',
|
||||
|
|
@ -14,33 +16,25 @@ return [
|
|||
|
||||
$comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value());
|
||||
|
||||
$newComment = [
|
||||
'page' => [
|
||||
'uri' => (string) $page->parent()->uri(),
|
||||
'title' => (string) $page->parent()->title(),
|
||||
],
|
||||
'file' => [
|
||||
'uuid' => (string) $file->uuid(),
|
||||
'pageIndex' => $data->filePageIndex,
|
||||
],
|
||||
$data = [
|
||||
'page' => $page,
|
||||
'file' => $file,
|
||||
'filePageIndex' => $data->filePageIndex,
|
||||
'position' => [
|
||||
'x' => null,
|
||||
'y' => null
|
||||
],
|
||||
'replies' => [],
|
||||
'text' => $data->text,
|
||||
'user' => [
|
||||
'name' => (string) $user->name(),
|
||||
'email' => (string) $user->email(),
|
||||
'uuid' => (string) $user->uuid(),
|
||||
'role' => (string) $user->role()
|
||||
],
|
||||
'user' => $user,
|
||||
'date' => (string) $data->date,
|
||||
'id' => $data->id,
|
||||
'type' => 'comment'
|
||||
];
|
||||
|
||||
$comments[$data->id] = $newComment;
|
||||
$newComment = new Comment($data);
|
||||
|
||||
$comments[$newComment->id()] = $newComment->toArray();
|
||||
|
||||
$newFile = $file->update([
|
||||
'comments' => $comments
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue