承接 gldrenthe89/nova-calculated-field 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Calculated Number Field

<?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

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 8
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-21