calculated-field icon indicating copy to clipboard operation
calculated-field copied to clipboard

Getting error when trying Overriding the Callback

Open techguydev opened this issue 5 years ago • 1 comments

Hi,

I am getting this error when I try to overwriting the callback like shown in the examples:

<?php
use Codebykyle\CalculatedField\BroadcasterField;
use Codebykyle\CalculatedField\ListenerField;

class MyResource extends Resource
{
    public function fields(Request $request) {
        return [    
            BroadcasterField::make('Sub Total', 'sub_total'),
            BroadcasterField::make('Tax', 'tax'),

            ListenerField::make('Total Field', 'total_field')
                ->calculateWith(function (Collection $values) {
                    $subtotal = $values->get('sub_total');
                    $tax = $values->get('tax');
                    return $subtotal + $tax;
                }),
        ];
    }
}

Argument 1 passed to App\Nova\Order::App\Nova\{closure}() must be an instance of App\Nova\Collection, instance of Illuminate\Support\Collection given

any thoughts?

techguydev avatar Apr 12 '20 17:04 techguydev

I used

use Illuminate\Support\Collection;

it works for me.

stefan-schroeer avatar Jun 08 '20 10:06 stefan-schroeer