Skip to content

Core Types and Enums

This reference lists the key package types used in source registration and metadata output.

Core classes

  • Ihasan\ReportBuilder\ReportBuilder
    • registerDataSource(DataSourceContract $dataSource): void
    • dataSource(string $key): DataSourceContract
    • dataSources(): array
  • Ihasan\ReportBuilder\DataSources\EloquentDataSource
    • default implementation for model-backed sources
  • Ihasan\ReportBuilder\Support\Field
    • fluent builder for FieldDefinition
  • Ihasan\ReportBuilder\DTOs\FieldDefinition
    • normalized field metadata object

Contracts

  • DataSourceContract
    • key(): string - machine key used in API paths
    • label(): string - human label shown in UI
    • fields(): array - all allowed FieldDefinition values
    • field(string $key): ?FieldDefinition - lookup one field by key
    • query(): EloquentBuilder|QueryBuilder - trusted base query for this source
    • applyScope(...): EloquentBuilder|QueryBuilder - apply user/tenant/request scopes
    • authorize(Request $request): bool - controls access to source metadata

Column definitions with Field

Each field key is public API metadata. column() maps that field to your trusted DB column.

php
Field::decimal('total_amount')
    ->label('Total Amount')
    ->column('orders.total_amount')
    ->sortable()
    ->groupable()
    ->filterable([FilterOperator::Eq, FilterOperator::Between])
    ->aggregates([AggregateFunction::Sum]);

Rule of thumb:

  • key = frontend contract
  • column = backend trusted mapping
  • operators/aggregates = allowlist for future query execution

Enums

  • FieldType
    • string, integer, decimal, boolean, date, datetime
  • FilterOperator
    • eq, neq, gt, gte, lt, lte, between, in, not_in, like, is_null, not_null
  • AggregateFunction
    • count, sum, avg, min, max

Exceptions you will commonly see

  • DataSourceAlreadyRegisteredException
  • DataSourceNotFoundException
  • InvalidDataSourceConfigurationException