adrema/app/Fileshare/Data/ResourceData.php

25 lines
489 B
PHP
Raw Normal View History

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,
'name' => pathinfo($dir, PATHINFO_FILENAME),
'parent' => pathinfo($dir, PATHINFO_DIRNAME),
]);
}
}