# tucker-eric/eloquentfilter architecture

> Architecture diagram of the GitHub repository tucker-eric/eloquentfilter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tucker-eric/eloquentfilter
- Repository: https://github.com/tucker-eric/eloquentfilter

## Overview

##### Main Components

a. Core Components:
- Filterable Trait (src/Filterable.php)
- ModelFilter Base Class (src/ModelFilter.php)
- Service Providers (for Laravel and Lumen)
- Command Generator (MakeEloquentFilter)

b. Integration Points:
- Laravel/Lumen Framework
- Eloquent ORM
- User's Application Models
- User's Model Filters

**┌─ Application Layer ─────────────────────┐**
- User's Laravel/Lumen Application        │
- ┌─ Models ──────┐  ┌─ Model Filters ─┐ │
- User Model    │──│ UserFilter      │ │
- Client Model  │──│ ClientFilter    │ │
- ┘  └────────────────┘ │

- ┼───────────────┼───────────┤
- ▼               ▼           │
- ┌─ Eloquent Filter Package ──────────┐│

- ┌─ Filterable Trait ────────────┐  ││
- filter()                     │  ││
- paginateFilter()            │  ││
- provideFilter()             │  ││
- ┘  ││

- ▼                     ││
- ┌─ ModelFilter Base Class ────┐  ││
- setup()                    │  ││
- related()                  │  ││
- input handling            │  ││
- relationship filtering    │  ││
- ┘  ││

- ┼─────────────────────┘│
- ▼                       │
- ┌─ Laravel/Lumen Integration ──────┐ │
- ServiceProvider                 │ │
- Commands                        │ │
- ┘ │
- ┘

##### Important Relationships

a. Data Flow:
- Request Input → Model::filter() → ModelFilter → Query Builder
- Relationship between Models and their respective Filters

b. Inheritance/Implementation:
- Models implementing Filterable trait
- Custom Filters extending ModelFilter base class

##### Additional Elements

- Different component types

b. Notes section highlighting:
- Configuration options
- Key features (relationship filtering, dynamic filters)
- Integration points

##### Implementation Details

- The package's role as a bridge between user input and Eloquent queries
- How the Filterable trait connects user models to the filtering system
- The relationship handling capabilities
- Service provider integration with Laravel/Lumen

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Application Layer"
        direction TB
        subgraph "Models"
            direction TB
            UserModel["User Model"]:::model
            ClientModel["Client Model"]:::model
        end

        subgraph "Model Filters"
            direction TB
            UserFilter["User Filter"]:::filter
            ClientFilter["Client Filter"]:::filter
        end

        UserModel --> UserFilter
        ClientModel --> ClientFilter
    end

    subgraph "Eloquent Filter Package"
        direction TB
        subgraph "Core Components"
            direction TB
            Filterable["Filterable Trait"]:::core
            ModelFilter["ModelFilter Base Class"]:::core
            Filterable --> ModelFilter
        end

        subgraph "Integration"
            direction TB
            LaravelProvider["Laravel Service Provider"]:::provider
            LumenProvider["Lumen Service Provider"]:::provider
            CommandGen["Make Filter Command"]:::tool
        end
    end

    subgraph "Framework Layer"
        direction TB
        Laravel["Laravel/Lumen Framework"]:::framework
        Eloquent["Eloquent ORM"]:::framework
    end

    %% Relationships
    UserFilter & ClientFilter --> ModelFilter
    Filterable --> Eloquent
    LaravelProvider & LumenProvider --> Laravel
    CommandGen --> ModelFilter

    %% Click Events
    click Filterable "https://github.com/tucker-eric/EloquentFilter/blob/master/src/Filterable.php"
    click ModelFilter "https://github.com/tucker-eric/EloquentFilter/blob/master/src/ModelFilter.php"
    click LaravelProvider "https://github.com/tucker-eric/EloquentFilter/blob/master/src/ServiceProvider.php"
    click LumenProvider "https://github.com/tucker-eric/EloquentFilter/blob/master/src/LumenServiceProvider.php"
    click CommandGen "https://github.com/tucker-eric/EloquentFilter/blob/master/src/Commands/MakeEloquentFilter.php"
    click UserModel "https://github.com/tucker-eric/EloquentFilter/blob/master/tests/classes/User.php"
    click ClientModel "https://github.com/tucker-eric/EloquentFilter/blob/master/tests/classes/Client.php"
    click UserFilter "https://github.com/tucker-eric/EloquentFilter/blob/master/tests/classes/UserFilter.php"
    click ClientFilter "https://github.com/tucker-eric/EloquentFilter/blob/master/tests/classes/ClientFilter.php"

    %% Styling
    classDef model fill:#3498db,stroke:#2980b9,color:white
    classDef filter fill:#2ecc71,stroke:#27ae60,color:white
    classDef core fill:#e74c3c,stroke:#c0392b,color:white
    classDef provider fill:#f1c40f,stroke:#f39c12,color:white
    classDef framework fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef tool fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        direction TB
        M["Models"]:::model
        F["Filters"]:::filter
        C["Core Components"]:::core
        P["Providers"]:::provider
        FW["Framework"]:::framework
        T["Tools"]:::tool
    end
```
