eom-plus / nova-rating-field
Laravel Rating Nova 字段。
dev-master
2023-10-19 21:47 UTC
Requires
- php: ^7.3|^8.0
- laravel/nova: ^4.0
This package is auto-updated.
Last update: 2024-09-19 23:55:44 UTC
README
这是一个用于在您的 Laravel Nova 应用中使用的 星级评分字段。此包高度基于 nikaia/nova-rating-field,与 Nova4 不兼容,并且有一段时间没有维护。
此 README 由原始作者编写,我们只是将其复制到这里并更改了包和字段名称。
使用 vue-star-rating。
安装
您可以通过 composer 将此包安装到使用 Nova 的 Laravel 应用中。
composer require eom-plus/nova-rating-field
接下来,您可以在您的 Nova 资源中使用 Eom-Plus\NovaRatingField\Rating
字段。
用法
public function fields(Request $request) { return [ // ... Rating::make('Rating')->min(0)->max(5)->increment(0.5)->hideFromIndex(), // Defining a custom style for the index page. Rating::make('Rating')->min(0)->max(5)->increment(0.5)->hideRating() ->withStyles([ 'star-size' => 15, 'rounded-corners' => true, ])->onlyOnIndex()->sortable(), // ... ]; }
定义属性
public function fields(Request $request) { Rating::make('Rating') // Miniumum rating (default: 0) ->min(0) // Maximum rating (default: 5) // This is how the component knows how many stars it should display. ->max(5) // Incremet (default: 1) // Can be float. The underlying eloquent colum must be defined as float in that case. // ie. 0.5 for half stars or 0.01 for fluid stars. ->increment(0.5) // Show rating value next to the stars ->hideRating() }
自定义样式
您可以使用 withStyles
方法来自定义组件样式。选项将传递给底层的 vue 组件样式属性。
默认值
public function fields(Request $request) { Rating::make('Rating') ->withStyles([ 'star-size' => 30, 'active-color' => 'var(--primary)', // Primary nova theme color. 'inactive-color' => '#d8d8d8', 'border-color' => 'var(--60)', 'border-width' => 0, 'padding' => 10, 'rounded-corners' => false, 'inline' => false, 'glow' => 0, 'glow-color' => '#fff', 'text-class' => 'inline-block text-80 h-9 pt-2', ]); }
⭐️ 表达您的支持
如果此项目对您有帮助,请给予 ⭐️ 吧!
您可能还喜欢的其他包
- Nova Rating Field - 一个用于在您的 Laravel Nova 应用中使用的星评级 Nova 4 字段。
- Nova Feedback Field - 一个用于在您的 Laravel Nova 应用中使用的表情反馈 Nova 4 字段。
- Nova Input Group - 一个 Laravel Nova 4 输入组格式化的文本字段。
- Nova Signature - 一个 Laravel Nova 4 签名板。
请查看我们的 GitHub 仓库,因为我们有很多分叉的 Nova 组件,这些组件包含一些尚未合并到主要所有者分支的修复。
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件。