file uploads

This commit is contained in:
2026-05-06 18:11:42 +03:00
parent 16e50e2d49
commit 5587e8b4b6
41 changed files with 685 additions and 1067 deletions
+6 -8
View File
@@ -11,7 +11,6 @@ class File implements FieldInterface, MinMaxInterface
{
public FieldInfo $info;
/**
* @param string[] $collections
*/
@@ -20,17 +19,18 @@ class File implements FieldInterface, MinMaxInterface
public string $label,
public string $mime = "",
public string $help = "",
public ?int $min = null,
public ?int $max = null,
public array $collections = [],
public ?int $min = null,
public ?int $max = null,
public array $collections = [],
public string $group = "",
)
{
) {
$this->info = new FieldInfo("file", "File", FieldType::FILE);
}
public function format(array $input, array $output): array
{
$value = $input[$this->name] ?? [];
$output[$this->name] = $value;
return $output;
}
@@ -51,6 +51,4 @@ class File implements FieldInterface, MinMaxInterface
return count($value) < $this->min;
}
}
+15 -12
View File
@@ -16,35 +16,38 @@ class Slug implements FieldInterface, RequiredInterface
public function __construct(
public string $name,
public string $label,
public bool $required = false,
public bool $nullable = false,
public ?int $min = null,
public ?int $max = null,
public bool $required = false,
public bool $nullable = false,
public ?int $min = null,
public ?int $max = null,
public string $default = "",
public string $help = "",
public bool $readonly = false,
public bool $readonly = false,
public string $source = "",
public string $group = "",
)
{
) {
$this->info = new FieldInfo("slug", "Slug", FieldType::STRING);
}
public function format(array $input, array $output): array
{
$value = !empty($input[$this->name]) ? (string)$input[$this->name] : null;
if(empty($value)){
$value = !empty($input[$this->name])
? (string) $input[$this->name]
: null;
if (empty($value)) {
$value = Str::slug($input[$this->source]);
}
$output[$this->name] = (new Nullable($this->nullable, $value, ""))->value();
$output[$this->name] = new Nullable(
$this->nullable,
$value,
"",
)->value();
return $output;
}
public function failRequired(mixed $value): bool
{
return empty(trim($value));
}
}