Download the PHP package thiktak/laravel-bootstrap-component-select2 without Composer
On this page you can find all versions of the php package thiktak/laravel-bootstrap-component-select2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thiktak/laravel-bootstrap-component-select2
More information about thiktak/laravel-bootstrap-component-select2
Files in thiktak/laravel-bootstrap-component-select2
Package laravel-bootstrap-component-select2
Short Description Laravel Bootstrap Blade components for Select2 & Bootstrap 5.
License MIT
Homepage https://github.com/Thiktak/laravel-bootstrap-component-select2
Informations about the package laravel-bootstrap-component-select2
Based on the components of https://github.com/bastinald/laravel-bootstrap-components
Installation
Run composer to install the package
Include css
Include on your resources/scss/app.scss the line:
Include Javascript
Include on your resources/js/app.js the line:
Run NPM
Use the component on your blades
This bs::select2 component use the bs:select of https://github.com/bastinald/laravel-bootstrap-components. You can use all the options of this component.
Here, the important part is the what="Model"
, with Model = App\Models\User or User
Configure your models
- Implement the trait
Select2Searchable
- Fill the protected variable $search2Fields with list of columns to be added in the where closure
- Implement the
__toString()
model method if you want to have a beautiful output
You can redefine the methods search2
and search2_export
if required.
You can also create a proxy and build you own query. The Select2Proxy implement automatically the Select2Searchable
trait.
The proxy should be on App\Models\Search2Proxies
folder.
Test the API
You can test the data exported to the select by opening directly /api/select2/search?what=User&q=a
If needed, you can use {{ route('api.select2.search') }}
Parameters
what
= the model to be used (i.e.: User or App\Models\User)q
= search keyword
Output:
- results: [{id: 1, text: "label"}]
- error: { code: 200, message: null }
Use the error code to know what happens.
TODO
- [X] Use Proxy for Model (App\Models\Search2Proxies\
Proxy)
Changelogs
- Added select2/autoload values (fetch data via API in order to keep label synchronization)
- Added possibility to fetch by ID or by term
- Added Proxy model
All versions of laravel-bootstrap-component-select2 with dependencies
bastinald/laravel-bootstrap-components Version ^2.0.15
apalfrey/select2-bootstrap-5-theme Version ^1.1.1