mirror of
https://github.com/brufdev/many-notes.git
synced 2026-01-24 03:49:35 -06:00
37 lines
805 B
PHP
37 lines
805 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Actions;
|
|
|
|
use App\Models\VaultNode;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
final readonly class UpdateVaultNode
|
|
{
|
|
/**
|
|
* @param array{
|
|
* parent_id?: int|null,
|
|
* is_file: bool,
|
|
* name: string,
|
|
* extension?: string|null,
|
|
* content?: string|null
|
|
* } $attributes
|
|
*/
|
|
public function handle(VaultNode $node, array $attributes): void
|
|
{
|
|
$relativeOriginalPath = new GetPathFromVaultNode()->handle($node);
|
|
$node->update($attributes);
|
|
|
|
if (!$node->wasChanged('name')) {
|
|
return;
|
|
}
|
|
|
|
$relativePath = new GetPathFromVaultNode()->handle($node);
|
|
Storage::disk('local')->move(
|
|
$relativeOriginalPath,
|
|
$relativePath,
|
|
);
|
|
}
|
|
}
|