sertxudeveloper/livewire-combobox
Composer 安装命令:
composer require sertxudeveloper/livewire-combobox
包简介
Add combobox to your Livewire forms
README 文档
README
Add combobox to your Livewire forms
Do you have a large dataset, and you need to be able to display it in a dropdown?
When a basic select input is not enough, you can use a combobox!
A combobox works like a select input, but instead of a dropdown, it displays a list of options that can be filtered by typing.
You will no longer need to download all the data at the startup, just get the data you're looking for.
Installation
You can install the package via composer:
composer require sertxudeveloper/livewire-combobox
Usage
Once you have installed the package, you can use it in your Livewire forms.
First, you need to execute the following command in your terminal:
php artisan combobox:make UsersCombobox -m User
This will create a new component in the app/Livewire directory.
The new UsersCombobox component will look like this:
<?php namespace App\Livewire; use App\Models\User; use SertxuDeveloper\LivewireCombobox\Components\Combobox; class UsersCombobox extends Combobox { /** @var class-string<Model> $model */ public string $model = User::class; }
As you can see, the $model property is set to the User model.
This means that the component will be able to query the database using this model.
By default, the component will display the name column of the model.
You can change this by setting the labelColumn property:
/** * The column to be shown as the label. * * @var string */ public string $labelColumn = 'title'; // Default: 'name'
To start using the component, you need to add it to your Livewire form.
<livewire:users-combobox>
@livewire('users-combobox')
You can also pass some parameters to the component:
<livewire:users-combobox name="author" label="Author" placeholder="Select a user">
Warning
If you don't pass any parameters, the component will use the default values.
It's recommended to pass the parameters to the component.
You can also add the values overriding the default values in the class.
Events
While interacting with the component, some events might be fired.
The name of the events depends on the component name, this allows you to have more than one combobox in your form.
selected-<component-name>: When the user selects an option from the dropdown.cleared-<component-name>: When the user clears the selected option.
These events will be fired up, so the parent component can react to the user interaction.
Note
The selected event contains the selected model as a parameter.
Adding filters
You can filter the results by adding filters to the component.
/** * Apply filters to the query. * * @param Builder $query * @return void */ protected function filter(Builder $query): void { $query->where('email', 'like', "%@example.com"); }
The filter method receives the query builder as a parameter, so you can add as many filters as you want.
The filters will be applied to the query before fetching the results, so you can use them to limit the options given to the user.
Testing
This package contains tests, you can run them using the following command:
composer test
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
Copyright © 2022 Sertxu Developer
sertxudeveloper/livewire-combobox 适用场景与选型建议
sertxudeveloper/livewire-combobox 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.32k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2022 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「sertxudeveloper」 「livewire-combobox」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sertxudeveloper/livewire-combobox 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sertxudeveloper/livewire-combobox 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sertxudeveloper/livewire-combobox 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Package for locking the user account due to inactivity
Attach media files to your models
Alfabank REST API integration
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
统计信息
- 总下载量: 3.32k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-10
