https://github.com/webard/nova-biloquent
https://github.com/webard/nova-biloquent
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/webard/nova-biloquent
- Owner: webard
- License: mit
- Created: 2024-01-10T16:35:08.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-04T16:56:39.000Z (about 2 years ago)
- Last Synced: 2025-11-27T16:46:24.870Z (6 months ago)
- Language: PHP
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NOVA BILOQUENT
Reports for Eloquent models, displayed as Nova resource.
See http://github.com/webard/biloquent for more info.
**Package is under development and in very early stage.**
## Define Resource
Sample base on Order model with total and created_at fields required.
Create file `App\Nova\OrderReport.php`:
```php
declare(strict_types=1);
namespace App\Nova;
use Webard\NovaBiloquent\NovaReport;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Number;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use App\Nova\User;
class OrderReport extends NovaReport
{
public static $model = \App\Reports\OrderReport::class;
public static string $datasetResource = \App\Nova\Order::class;
public function reportFields(NovaRequest $request): array
{
return [
Text::make('Year', 'year')->sortable(),
Text::make('Month', 'month')->sortable(),
Text::make('Day', 'day')->sortable(),
Text::make('Date', 'date')->sortable(),
BelongsTo::make('Customer', 'customer', User::class)->sortable(),
Number::make('Total orders', 'total_orders')->sortable()->filterable(),
Number::make('Avg. amount', 'average_amount')->sortable()->filterable(),
];
}
}