Ecommerce Report Walkthrough
After this page, you can design a real data source for an ecommerce app and understand exactly what this package can do now versus what is planned for export.
Scenario
- 1000 users
- each user has 10 orders
- each order amount is 300 taka
Expected totals:
- total orders =
1000 * 10 = 10,000 - total revenue =
10,000 * 300 = 3,000,000taka
What works today
Current package phase supports:
- registering data sources
- defining safe columns/fields
- exposing metadata through API
Current package phase does not yet include:
- preview/run query execution endpoints
- CSV export
- XLS/XLSX export
Step 1: Design your source fields
Use only trusted fields needed for reporting.
php
new EloquentDataSource(
key: 'orders',
label: 'Orders',
model: Order::class,
fields: [
Field::integer('user_id')
->label('User')
->column('orders.user_id')
->groupable()
->filterable([FilterOperator::Eq, FilterOperator::In]),
Field::decimal('total_amount')
->label('Order Amount')
->column('orders.total_amount')
->sortable()
->groupable()
->filterable([FilterOperator::Eq, FilterOperator::Gt, FilterOperator::Between])
->aggregates([AggregateFunction::Sum, AggregateFunction::Avg]),
Field::dateTime('created_at')
->label('Order Date')
->column('orders.created_at')
->sortable()
->filterable([FilterOperator::Gte, FilterOperator::Lte]),
],
);Step 2: Register the data source
php
$reportBuilder->registerDataSource(new OrdersDataSource());Step 3: Verify metadata
bash
curl http://your-app.test/report-builder/sources/ordersYou should see field metadata for user_id, total_amount, and created_at.
How export will work (planned flow)
mermaid
flowchart LR
UI["FrontendUser"] -->|"SelectSavedReport + format(csv/xlsx)"| ExportAPI["ReportExportController(planned)"]
ExportAPI --> Service["ExportService(planned)"]
Service --> Engine["QueryEngine(planned)"]
Engine --> Dataset["DatasetRows"]
Dataset --> CsvExporter["CsvExporter(planned)"]
Dataset --> ExcelExporter["ExcelExporter(planned)"]
CsvExporter --> Storage["StorageDisk"]
ExcelExporter --> Storage
Storage --> UIPractical note for your example
For your ecommerce dataset, the desired report is:
- group by
user_id - aggregate
sum(total_amount)as total spend per user
When preview/run/export phase lands, this same source definition will power that output safely.