mirror of
https://github.com/brufdev/many-notes.git
synced 2026-01-25 04:18:51 -06:00
Add the "move nodes" feature
This commit is contained in:
@@ -11,11 +11,11 @@ final readonly class UpdateVaultNode
|
||||
{
|
||||
/**
|
||||
* @param array{
|
||||
* parent_id: int|null,
|
||||
* is_file: bool,
|
||||
* name: string,
|
||||
* extension: string|null,
|
||||
* content: string|null
|
||||
* parent_id?: int|null,
|
||||
* is_file?: bool,
|
||||
* name?: string,
|
||||
* extension?: string|null,
|
||||
* content?: string|null
|
||||
* } $attributes
|
||||
*/
|
||||
public function handle(VaultNode $node, array $attributes): void
|
||||
@@ -30,12 +30,16 @@ final readonly class UpdateVaultNode
|
||||
Storage::disk('local')->put($originalPath, $attributes['content'] ?? '');
|
||||
}
|
||||
|
||||
if (!$node->wasChanged('name')) {
|
||||
return;
|
||||
// Rename node on disk
|
||||
if ($node->wasChanged('name')) {
|
||||
$path = new GetPathFromVaultNode()->handle($node);
|
||||
Storage::disk('local')->move($originalPath, $path);
|
||||
}
|
||||
|
||||
// Rename node on disk
|
||||
$path = new GetPathFromVaultNode()->handle($node);
|
||||
Storage::disk('local')->move($originalPath, $path);
|
||||
// Move node on disk
|
||||
if ($node->wasChanged('parent_id')) {
|
||||
$path = new GetPathFromVaultNode()->handle($node);
|
||||
Storage::disk('local')->move($originalPath, $path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user