Tag#

Tag holds free-text tags in a JSON list column, tag in the descriptor, an array or ?array property, shown as chips and edited in a chips input:

Tag::make('keywords')->suggestions(['eco', 'bestseller', 'gift'])->filterable(),
A Tag field on the product form: Keywords, with eco and bestseller as chips and the hint Type a tag and press Enter
A Tag field on the product form: Keywords, with eco and bestseller as chips and the hint Type a tag and press Enter

suggestions() (a list, or a closure run once when the resource compiles) only proposes values; any other text is a valid tag. A written list is normalized: each tag trimmed, empty ones dropped, duplicates dropped ignoring case with the first spelling kept (["Eco", "eco"] stores ["Eco"]), in the order sent. An empty list stores null where the column allows it. A tag longer than maxLength() (50 characters by default) or that is not text is refused at its index (keywords.2), and a list longer than maxTags() (20 by default) with too_many_entries.

A filterable tag field filters by any (the default for a bare value, filter[keywords]=eco,gift) or all of a list of tags, through the same JSON list SQL as a multiple select on both dialects, plus null and nnull on a nullable column. A filter compares each tag exactly as it is stored, so eco does not match a stored Eco; send a list as an array (filter[keywords][all][]=...) when a tag holds a comma. The list’s filter bar separates the tags it sends by commas, so a tag that holds a comma cannot be filtered from the UI; the API’s array form filters it. A tag field is never sorted, grouped, searched, summarized or edited inline. It is exported as JSON and imported from JSON or |-separated text.

It takes the common modifiers too.