2024-06-28 23:56:34 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Fileshare\Data;
|
|
|
|
|
|
|
|
use Spatie\LaravelData\Data;
|
|
|
|
|
|
|
|
class ResourceData extends Data
|
|
|
|
{
|
|
|
|
|
|
|
|
public function __construct(public $name, public $path, public $parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|