2024-06-28 23:56:34 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Fileshare\Data;
|
|
|
|
|
|
|
|
use Spatie\LaravelData\Data;
|
|
|
|
|
|
|
|
class ResourceData extends Data
|
|
|
|
{
|
|
|
|
|
2024-06-29 11:18:40 +02:00
|
|
|
public function __construct(public string $name, public string $path, public string $parent)
|
2024-06-28 23:56:34 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function fromString(string $path): self
|
|
|
|
{
|
|
|
|
$dir = '/' . trim($path, '\\/');
|
|
|
|
|
|
|
|
return self::from([
|
|
|
|
'path' => $dir,
|
2024-06-29 10:34:40 +02:00
|
|
|
'name' => pathinfo($dir, PATHINFO_BASENAME),
|
2024-06-28 23:56:34 +02:00
|
|
|
'parent' => pathinfo($dir, PATHINFO_DIRNAME),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|