Skip to content

Field types ​

TypeAcceptsStored and returned asSettings
textstringstringmax_length (255)
textareastringstringmax_length (65535)
emailemail addressstringmax_length (255)
urlabsolute URLstringmax_length (2048)
phonedigits, spaces, ( ) . -, leading +trimmed string
numberint, float, numeric stringint or float
integerint or integer stringint
decimalnumber with at most places decimalsstring padded to places, for example "12.50"places (2)
booleantrue, false, 1, 0, "1", "0"bool
dateanything Laravel's date rule accepts"Y-m-d"
datetimeanything Laravel's date rule acceptsUTC ISO 8601, for example "2026-11-09T14:30:00Z"
time"H:i" or "H:i:s""H:i:s"
select / radioone option keystringoptions (required)
multiselect / checkboxa list of option keyslist of strings, duplicates removedoptions (required)
jsonarray, int, float, bool, or a string of JSON textdecoded value

Settings ​

Pass settings when you create the field. They merge over the type's defaults.

php
CustomFields::create([
    'model' => Reservation::class,
    'key' => 'deposit',
    'label' => 'Deposit',
    'type' => 'decimal',
    'settings' => ['places' => 2],
]);

CustomFields::create([
    'model' => Reservation::class,
    'key' => 'amenities',
    'label' => 'Amenities',
    'type' => 'multiselect',
    'settings' => ['options' => ['parking' => 'Parking', 'breakfast' => 'Breakfast']],
]);

Notes ​

  • Options are a map of stored value to label: ['vip' => 'VIP', 'walk_in' => 'Walk-in']. The stored value is always the key, as a string.
  • Decimal values are stored as strings, so money keeps its exact value. They still compare as numbers in queries.
  • Datetime values without a timezone are read in your app timezone, then converted to UTC.
  • JSON fields treat strings as JSON text. '{"a":1}' is stored as ['a' => 1], and 'hello' is rejected. To store a plain string, use a text field.
  • Phone checks only the characters. It doesn't know real numbering plans. For that, register your own type backed by a library such as libphonenumber.

Released under the MIT License.