laravel-enso/select
Select
Description
Select provides the server-side option and typeahead builders used by Laravel Enso select controls.
The package ships traits for controller-style endpoints and a configurable Options response service that supports selected values, search queries, plain filters, pivot filters, resources, appended attributes, and nested relation attributes.
It can be used inside or outside Enso when a Laravel application needs consistent server-side select data feeds.
Installation
Install the package:
composer require laravel-enso/select
Publish the configuration if you want to change defaults such as trackBy, searchMode, or query attributes:
php artisan vendor:publish --tag=select-config
Features
OptionsBuildertrait for standard select endpoints.TypeaheadBuildertrait for typeahead payload conversion.Optionsservice implementingResponsable.- Search across local attributes and nested relation attributes.
- Support for selected values, pagination limit, params, pivot params, custom resources, and model appends.
Usage
Typical options endpoint:
class Options
{
use OptionsBuilder;
protected string $model = Company::class;
protected array $queryAttributes = ['name', 'person.name'];
}
Typical typeahead endpoint:
class Typeahead
{
use TypeaheadBuilder;
protected string $model = Company::class;
}
Supported request inputs include:
valuequerypaginatetrackBysearchModeparamspivotParams
API
Builder traits
LaravelEnso\\Select\\Traits\\OptionsBuilderLaravelEnso\\Select\\Traits\\TypeaheadBuilder
Response service
LaravelEnso\\Select\\Services\\Options
Behavior:
- merges selected values ahead of fresh results
- applies direct and pivot relation filters
- performs filter-based search through
laravel-enso/filters - sorts by the first query attribute when possible
- returns a collection or an API resource collection
Depends On
Required Enso packages:
Companion frontend package:
Contributions
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!
Related Packages
Bootstrap Select data builder with server-side data fetching capability and a Vu...
Server-side data builder for Chart.js, with a VueJS component for the frontend.