add parent node to node, fix type of null
This commit is contained in:
parent
483110f773
commit
021a2a6f15
5 changed files with 24 additions and 1 deletions
|
|
@ -22,10 +22,19 @@ class CreateNode
|
|||
if ($text === null) {
|
||||
throw new DomainException("Text with id: $id doesnt exist");
|
||||
}
|
||||
if ($request->parentNodeId === null) {
|
||||
return $this->nodeRepo->create(new CreateNodeDto(
|
||||
text: $text,
|
||||
title: $request->title,
|
||||
parentNode: null,
|
||||
));
|
||||
}
|
||||
$parentNode = $this->nodeRepo->find($request->parentNodeId);
|
||||
|
||||
return $this->nodeRepo->create(new CreateNodeDto(
|
||||
text: $text,
|
||||
title: $request->title,
|
||||
parentNode: $parentNode,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue