gldrenthe89/nova-calculated-field
最新稳定版本:v2.4.1
Composer 安装命令:
composer require gldrenthe89/nova-calculated-field
包简介
A server side calculated field for Laravel Nova
README 文档
README
This packages is created after the package from codebykyle But after an extensive refactor and updating a lot of VueJS code to the latest Laravel Nova code I made this in to a new package.
New features
[Release V2.3]
-- Fixed issue where you can't edit a listener field
-- Added Date Broadcaster field
-- Added Date Listener field
-- Added 'calculate' buttons to all visible Listener Fields
-- Added ability to turn of calculation on update forms.
[changes up to V2.2]
-- BelongsTo Broadcaster field
-- MorphTo Broadcaster field
-- Currency Listener Field
-- Hidden Listener Field
-- Code has been completely updated to latest Nova (2021-03-18)
Below pieces of the old Documentation from codebykyle I'm not really good at writing documentation. So please feel free to creat a PR for it.
Installation
Install the package via composer:
composer require gldrenthe89/nova-calculated-field
Example
<?php use Gldrenthe89\NovaCalculatedField\BroadcasterField; use Gldrenthe89\NovaCalculatedField\ListenerField; class MyResource extends Resource { public function fields(Request $request) { return [ BroadcasterField::make('Sub Total', 'sub_total') ->broadcastTo('total'), // can either be a String or an Array BroadcasterField::make('Tax', 'tax') ->broadcastTo('total'), // can either be a String or an Array ListenerField::make('Total Field', 'total_field') ->listensTo('total') // can either be a String or an Array ->calculateWith(function (Collection $values) { $subtotal = $values->get('sub_total'); $tax = $values->get('tax'); return $subtotal + $tax; }), BroadcasterField::make('Senior Discount', 'senior_discount') ->broadcastTo('discount'), // can either be a String or an Array BroadcasterField::make('Coupon Discount', 'coupon_amount') ->broadcastTo('discount'), // can either be a String or an Array ListenerField::make('Total Discount', 'total_discount') ->listensTo('discount') // can either be a String or an Array ->disableCalculationOnUpdate() // Only when to disable on Update forms ->calculateWith(function (Collection $values) { $seniorDiscount = $values->get('senior_discount'); $couponAmount = $values->get('coupon_amount'); return $seniorDiscount + $couponAmount; }) ]; } }
统计信息
- 总下载量: 14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-01-21