1. Go to this page and download the library: Download webard/nova-havingable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webard / nova-havingable example snippets
class Order extends Resource
{
public static $model = \App\Models\Order::class;
public static function indexQuery(NovaRequest $request, $query)
{
return $query
->withSum('lines', 'amount')
->withSum('lines', 'quantity');
}
public function resourceFields(NovaRequest $request): array
{
return [
ID::make('ID', 'id'),
Number::make('Items Sum', 'lines_sum_quantity')
->sortable()
->exceptOnForms(),
Number::make('Amount Sum', 'lines_sum_amount')
->sortable()
->exceptOnForms(),
];
}
}