javii-script/default-value-filterable
最新稳定版本:2.0.0
Composer 安装命令:
composer require javii-script/default-value-filterable
包简介
A Nova macro that streamlines setting a default value in addition to enabling filtering functionality on a field.
README 文档
README
Nova Field Default Filter Macro is a custom macro for Laravel Nova that simplifies the process of setting default values and enabling filtering capabilities for fields.
Features
- Default Value for Filters: Easily set default values for fields when filters are applied.
- Customizable Filtering Logic: Define how the filtering is applied with custom callback functions.
- Seamless Integration: Designed specifically for Laravel Nova resources.
Screenshot
Requirements
To use this package, ensure your environment meets the following requirements:
- PHP:
^8.1 - Laravel Nova:
^5.0
Installation
Install the package via Composer:
composer require javii-script/default-value-filterable
Usage
The defaultFilterable macro makes it easy to define a default value for filters, enhancing the functionality of your Nova resources.
Basic Example
Text::make('Name') ->defaultFilterable(function () { return 'John Doe'; }),
In this example, the Name field will have a default filter value of John Doe.
Advanced Example with Custom Filtering Logic
Text::make('Name') ->defaultFilterable(function () { return 'John Doe'; }, function ($request, $query, $value, $attribute) { $query->where($attribute, 'LIKE', "{$value}%"); }),
In this example:
- Default Value: The Name field will default to John Doe when filtering.
- Custom Filtering: The filtering logic will apply a LIKE clause to match records where the Name starts with the filter value.
Contributing
Contributions are welcome! If you have ideas for improvements or find any issues, feel free to open an issue or submit a pull request.
License
This package is open-sourced software licensed under the MIT license.
Links
统计信息
- 总下载量: 9.63k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-25
