fix Reply php class

This commit is contained in:
isUnknown 2024-10-30 09:56:16 +01:00
parent f5ffe312e2
commit 14f409abec
3 changed files with 14 additions and 144 deletions

View file

@ -6,129 +6,4 @@ Uuid: s0lNtRA0Z7ybTCWG
----
Template: document
----
Comments:
m2unqxu0:
page:
uri: projects/miss-dior-blooming-bouquet
title: Miss Dior Blooming Bouquet
file:
uuid: file://s0lNtRA0Z7ybTCWG
pageIndex: 1
position:
x: null
y: null
replies:
m2vmx97a:
page:
uri: projects/miss-dior-blooming-bouquet
title: Miss Dior Blooming Bouquet
file:
uuid: file://s0lNtRA0Z7ybTCWG
pageIndex: 1
text: Test de réponse
user:
name: Adrien Payet
email: adrien.payet@outlook.com
uuid: user://WWjXgPWk
role: admin
date: 2024-10-30T09:48:49+01:00
id: m2vmx97a
type: comment
text: >
Un commentaire écrit par Adrien pour
tester.
user:
name: Adrien Payet
email: adrien.payet@outlook.com
uuid: user://WWjXgPWk
role: admin
date: 2024-10-29T17:24:08+01:00
id: m2unqxu0
type: comment
m2unytm0:
page:
uri: projects/miss-dior-blooming-bouquet
title: Miss Dior Blooming Bouquet
file:
uuid: file://s0lNtRA0Z7ybTCWG
pageIndex: 1
position:
x: null
y: null
replies:
m2unz4j1:
page:
uri: projects/miss-dior-blooming-bouquet
title: Miss Dior Blooming Bouquet
file:
uuid: file://s0lNtRA0Z7ybTCWG
pageIndex: 1
text: Réponse à un commentaire
user:
name: Utilisateur Dior
email: utilisateur@dior.com
uuid: user://HfuumN8s
role: client
date: 2024-10-29T17:30:30+01:00
id: m2unz4j1
type: comment
text: Un autre commentaire
user:
name: Utilisateur Dior
email: utilisateur@dior.com
uuid: user://HfuumN8s
role: client
date: 2024-10-29T17:30:15+01:00
id: m2unytm0
type: comment
m2vmw7ct:
page:
uri: >
projects/miss-dior-blooming-bouquet/client-brief
title: Brief client
file:
uuid: file://s0lNtRA0Z7ybTCWG
pageIndex: 1
replies: [ ]
text: >
encore un test après créaton classes
php comment
user:
name: Adrien Payet
email: adrien.payet@outlook.com
uuid: user://WWjXgPWk
role: admin
date: 2024-10-30T09:48:00+01:00
id: m2vmw7ct
type: comment
position:
x: null
y: null
m2vmwvmt:
page:
uri: >
projects/miss-dior-blooming-bouquet/client-brief
title: Brief client
file:
uuid: file://s0lNtRA0Z7ybTCWG
pageIndex: 1
replies: [ ]
text: >
encore un test après créaton classes
php comment
user:
name: Adrien Payet
email: adrien.payet@outlook.com
uuid: user://WWjXgPWk
role: admin
date: 2024-10-30T09:48:31+01:00
id: m2vmwvmt
type: comment
position:
x: null
y: null
Template: document

View file

@ -40,7 +40,7 @@ return [
'comments' => $comments
]);
$user->sendNotification('comments', $newComment);
$user->sendNotification('comments', $newComment->toArray());
return getFileData($newFile);
}

View file

@ -1,5 +1,7 @@
<?php
use adrienpayet\comments\Reply;
return [
'pattern' => '(:all)reply-comment.json',
'method' => 'POST',
@ -14,34 +16,27 @@ 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,
'parentId' => $data->parentId,
'file' => $file,
'filePageIndex' => $data->filePageIndex,
'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->parentId]['replies'][$data->id] = $newComment;
$newReply = new Reply($data);
$comments[$newReply->parentId()]['replies'][$newReply->id()] = $newReply->toArray();
$newFile = $file->update([
'comments' => $comments
]);
$user->sendNotification('comments', $newComment);
$user->sendNotification('comments', $newReply->toArray());
return getFileData($newFile);
}