Skip to content

Repository

When handling data in your repository, you may need to override specific functions based on the source of the data. Here are the guidelines for overriding these functions:

Handling Data from an API

If the record is an array or iterable (e.g., data received from an API call), override the following functions in your repository:

  • Override getGridData for Data Retrieval:

    php
    public function getGridData(array $filters = []): ?iterable
    {
        return null;
    }
  • Override applyFilterData for Custom Data Filtering:

    php
    public function applyFilterData(Collection $data, array $filters): Collection
    {
        // Implement custom filtering logic here
    }

Handling Data from a Database

If the record is populated from a database table (e.g., data received by an SQL query), override the following functions in your repository:

  • Override getGridQuery for Query Building:

    php
    public function getGridQuery(): ?Builder
    {
        return null;
    }
  • Override applyFilterQuery for Custom Query Filtering:

    php
    public function applyFilterQuery(Builder $query, array $filters): Builder
    {
        // Implement custom filtering logic here
    }

These overrides allow you to customize how data is retrieved and filtered, whether it comes from an API or a database, providing greater flexibility in handling different data sources.

Developed By ❤️ Taki Elias