adrema/app/Fileshare/Data/FileshareResourceData.php

31 lines
756 B
PHP
Raw Permalink Normal View History

2024-06-29 14:36:35 +02:00
<?php
namespace App\Fileshare\Data;
2024-06-30 23:36:44 +02:00
use App\Fileshare\Models\Fileshare;
use Illuminate\Filesystem\FilesystemAdapter;
2024-06-29 14:36:35 +02:00
use Spatie\LaravelData\Attributes\MapInputName;
use Spatie\LaravelData\Attributes\MapOutputName;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
#[MapInputName(SnakeCaseMapper::class)]
#[MapOutputName(SnakeCaseMapper::class)]
class FileshareResourceData extends Data
{
public function __construct(public int $connectionId, public string $resource)
{
}
2024-06-30 23:36:44 +02:00
public function getConnection(): Fileshare
{
return Fileshare::find($this->connectionId);
}
public function getStorage(): FilesystemAdapter
{
return $this->getConnection()->type->getFilesystem();
}
2024-06-29 14:36:35 +02:00
}