file uploads
This commit is contained in:
@@ -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
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user