Skip to content

arqel-dev/fields — API Reference

Namespace Arqel\Fields\. 21 canonical field types + ValidationBridge + macro registry.

Arqel\Fields\Field (abstract)

Base of every Field. __construct is final by design — subclasses only declare protected string $type and protected string $component.

Fluent setters (via traits)

TraitSetters
baselabel, placeholder, helperText, default, readonly, disabled, columnSpan, columnSpanFull, dehydrated, live, liveDebounced, afterStateUpdated
HasValidationrequired, nullable, rules, rule, unique, maxLength, minLength, requiredIf, requiredWith, requiredWithout, validationAttribute, validationMessage
HasVisibilityhidden, hiddenOnCreate, hiddenOnEdit, hiddenOnDetail, hiddenOnTable, visibleOn(string|array), hiddenOn(string|array), visibleIf(Closure), hiddenIf(Closure)
HasDependenciesdependsOn(string|array), resolveOptionsUsing(Closure)
HasAuthorizationcanSee(Closure), canEdit(Closure)

Oracles

php
isVisibleIn(string $context, ?Model $record = null): bool   // create|edit|detail|table
canBeSeenBy(?Authenticatable $user, ?Model $record = null): bool
canBeEditedBy(?Authenticatable $user, ?Model $record = null): bool
isDisabled(?Model $record = null): bool
isDehydrated(?Model $record = null): bool
getValidationRules(): array
handleDependencyUpdate(array $formState, string $changedField): array

Arqel\Fields\FieldFactory (final)

Public factory. Don't call new TextField('name') — use FieldFactory::text('name') (common alias: use Arqel\Fields\FieldFactory as Field;).

MethodReturns
Field::text/textarea/email/url/password/slug(name)TextField/TextareaField/...
Field::number/currency(name)NumberField/CurrencyField
Field::boolean/toggle(name)BooleanField/ToggleField
Field::select/multiSelect/radio(name)SelectField/MultiSelectField/RadioField
Field::belongsTo(name, Resource)BelongsToField
Field::hasMany(name, Resource)HasManyField
Field::date/dateTime(name)DateField/DateTimeField
Field::file/image(name)FileField/ImageField
Field::color/hidden(name)ColorField/HiddenField
Field::macro(name, Closure) / Field::hasMacro(name)macro registry
Field::register(type, class)custom-type registry

Field Types — specific props

ClassExtra setters
TextFieldmaxLength, minLength, pattern, autocomplete, mask
TextareaFieldrows, cols
EmailField(default rule email)
UrlField(default rule url)
PasswordFieldrevealable
SlugFieldfromField, separator, reservedSlugs, uniqueIn
NumberFieldmin, max, step, integer, decimals
CurrencyFieldprefix, suffix, thousandsSeparator, decimalSeparator, decimals
BooleanFieldinline
ToggleFieldonColor, offColor, onIcon, offIcon
SelectFieldoptions(array|Closure), optionsRelationship, searchable, multiple, native, creatable, createOptionUsing, allowCustomValues
BelongsToFieldfactory make($name, $relatedResource), searchable, preload, searchColumns, optionLabel(Closure), relationship(name, ?query)
HasManyFieldfactory make($name, $relatedResource), canAddRecords, canEditRecords
DateFieldformat, displayFormat, minDate, maxDate, closeOnDateSelection, timezone
DateTimeFieldadds seconds(bool)
FileFielddisk, directory, visibility, maxSize, acceptedFileTypes, multiple, reorderable, using(STRATEGY_*)
ImageFieldadds imageCropAspectRatio, imageResizeTargetWidth
ColorFieldpresets, format('hex'|'rgb'|'hsl'), alpha
HiddenField(no extra setters)

Arqel\Fields\ValidationBridge (final)

Translates Laravel rule arrays to a Zod schema. 19 built-in translators.

MethodFunction
translate(array $rules): stringZod schema (e.g.: z.string().email().min(1).max(255).nullable())
register(string $rule, Closure)Register a custom translator
hasRule(string), flush()Utilities

Unknown rules are silently skipped (confirmed, password, current_password are server-only).

Arqel\Fields\EagerLoadingResolver (final)

resolve(array<Field>): array<int, string> extracts relation names from BelongsToField and HasManyField for Builder::with(...). Auto dedupe.

HTTP Controllers

ControllerEndpointFunction
FieldSearchControllerGET {panel}/{resource}/fields/{field}/search?q=Async search for BelongsToField (max 20 results, throttle 30/min)
FieldUploadControllerPOST/DELETE {panel}/{resource}/fields/{field}/uploadUpload/delete for FileField

Macros & Custom

php
// AppServiceProvider::boot
Field::macro('priceBRL', fn (string $name) =>
    Field::currency($name)->prefix('R$ ')->thousandsSeparator('.')->decimalSeparator(',')
);

// Custom type
Field::register('rating', RatingField::class);

Artisan commands

CommandFunction
arqel:field {name} {--force}Generates app/Arqel/Fields/{Name}Field.php + resources/js/Arqel/Fields/{Name}Input.tsx stubs

MIT License — built with Inertia + React + Laravel.