LaraUI - V1.0

Uniq

The <x-xf::uniq> component is a dynamic input field designed to ensure unique values (e.g., username, slug) by checking against a specified model. It supports real-time uniqueness validation, field customization, auto-fill append behavior, and conditional triggering — ideal for form fields requiring uniqueness enforcement.

📄 <x-xf::uniq>

📘 Description

The <x-xf::uniq> component is used for creating form inputs that require unique values validated against a Laravel Eloquent model. It allows appending extra request values, triggering validation on specific HTML events, and checking uniqueness against a defined database column.

Perfect for slug fields, usernames, and other inputs that need to stay unique across a dataset. This field is configurable and integrates smoothly into dynamic form systems.

✅ Usage Example

<x-xf::uniq 
    name="slug" 
    label="Post Slug" 
    :model="\App\Models\Post::class" 
    field="slug" 
    :skip="['draft', 'example']" 
    :append="['category']" 
    trigger="blur" 
    size="md" 
    :attr="['placeholder' => 'Enter unique slug']" 
    class="mb-4" 
/>

🔑 Props

Name Type Required Default Description
name string Name of the input field. Also used as the default DB column for validation if field is not set.
model string|Model The Eloquent model to be used for checking uniqueness.
size string 'md' Input size: sm, md, or lg.
skip array [] Array of values that should be skipped during DB uniqueness check. Useful for updates or ignoring reserved words.
attr array [] Extra HTML attributes like placeholder, maxlength, etc.
append array [] Additional input field names to include in the request payload during validation. Useful for scoped uniqueness (e.g., by category).
label string|null null Label displayed above the input field.
class string|null null Custom CSS class for styling.
field string|null name Specifies the DB column used for validation. Defaults to the name prop if not set.
trigger string|null null HTML event name (e.g., blur, keyup) to trigger the uniqueness validation.

🛡 Features

  • ✅ Real-time uniqueness check against Eloquent models
  • ✅ Flexible DB field selection via field
  • ✅ HTML event binding using trigger (e.g., blur, keyup)
  • ✅ Smart append and skip handling for scoped or conditional validation