PHPackages                             byerikas/eloquent-bigquery - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. byerikas/eloquent-bigquery

ActiveLibrary[Database &amp; ORM](/categories/database)

byerikas/eloquent-bigquery
==========================

Simple select SQL generator and query service in the syntax style of Laravel's Eloquent for Google BigQuery.

1.1.1(1mo ago)1186[1 issues](https://github.com/byErikas/eloquent-bigquery/issues)MITPHPCI passing

Since Mar 16Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/byErikas/eloquent-bigquery)[ Packagist](https://packagist.org/packages/byerikas/eloquent-bigquery)[ RSS](/packages/byerikas-eloquent-bigquery/feed)WikiDiscussions v1.x.x Synced 3w ago

READMEChangelog (9)Dependencies (8)Versions (10)Used By (0)

Eloquent BigQuery
=================

[](#eloquent-bigquery)

 [![tests Status](https://github.com/byErikas/cache-tags/actions/workflows/tests.yml/badge.svg)](https://github.com/byErikas/eloquent-bigquery/actions) [![](https://camo.githubusercontent.com/440243f62bcfac1f325dece9f6d4c204ae136ce29914eb8f1a7ad0ed293fe378/68747470733a2f2f636f6465636f762e696f2f67682f62794572696b61732f656c6f7175656e742d62696771756572792f67726170682f62616467652e7376673f746f6b656e3d4766656c53516a304651)](https://codecov.io/gh/byErikas/eloquent-bigquery) [![Packagist Version](https://camo.githubusercontent.com/700543849f9e28e628e8ad5cf7a0a2e925a5e64d8c24e5b199d6c781476b5af2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62796572696b61732f656c6f7175656e742d6269677175657279)](https://packagist.org/packages/byerikas/eloquent-bigquery) [![GitHub License](https://camo.githubusercontent.com/e3801efab0fe9579532136bcb6e9cf9240be864d1a95b1daba0bd441b3f6facc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f62796572696b61732f656c6f7175656e742d6269677175657279)](https://github.com/byErikas/eloquent-bigquery/blob/v1.x.x/LICENSE)

Simple select SQL generator and query service in the syntax style of Laravel's Eloquent for Google BigQuery.

Usage
=====

[](#usage)

Queries can be built using the provided `Builder` facade:

```
use ByErikas\EloquentBigQuery\Builder;

$query = Builder::table("test", "table_alias")
  ->select(["column AS column_alias"])
  ->where("columnA", "value")
  ->whereIn("columnB", [1, 2, 3])
  ->whereBetween("columnC", 1, 10)
  ->limit(10)
  ->offset(5)
  ->orderBy("column_alias", "desc");
```

And their SQL can be returned by using the `toSQL` method:

```
$query = Builder::table("test")
  ->select(["column", "column2"])
  ->whereBetween("column", 1, 2);

$sql = $query->toSQL(); //returns: "SELECT column, column2 FROM `test` WHERE column BETWEEN 1 AND 2"
```

Executing the queries can be done using the `QueryService` facade:

```
use ByErikas\EloquentBigQuery\Facades\QueryService;

$result = QueryService::query($query)->execute();

[$resultsA, $resultsB] = QueryService::query([$queryA, $queryB])->execute(); //multiple queries are supported
```

Selecting predefined columns or aggregations on queries can be done using `selectAggregations` method:

```
Builder::table("test")->selectAggregations(["metric-1"]);
```

Joins are supported using variuos `join` / `queryJoin` methods. Complex `where` / `having` statements are supported by passing a function to the first parameter of `where` / `having` methods:

```
use ByErikas\EloquentBigQuery\Join;

Builder::table("test")
  ->select(["column"])
  ->join("test1", "t1", function (Join $query) {
    $query->where("time", "test.time");
  });

use ByErikas\EloquentBigQuery\Where;

Builder::table("test")
  ->select(["column"])
  ->where(function (Where $query) {
    $query->where("columnA", true)
      ->whereBetween("columnB", "1000-01-01", "2000-01-01", "or");
  });

use ByErikas\EloquentBigQuery\Having;

Builder::table("test")
  ->select(["column"])
  ->having(function (Having $query) {
    $query->having("columnA", 100);
  });
```

Installation
============

[](#installation)

The package can be installed using:

```
composer require byerikas/eloquent-bigquery

```

Configuration
=============

[](#configuration)

Before usage it's recommended to define the default BigQuery client config in your `AppServiceProvider.php`:

```
use ByErikas\EloquentBigQuery\Facades\QueryService;

public function boot(): void {

  //...

  QueryService::setClientConfig(["keyFile" => ...]);

  //...
}
```

As well as register any custom / complex select metrics or aggregations that you may be storing elsewhere:

```
use ByErikas\EloquentBigQuery\Facades\AggregationsRepository;

public function boot(): void {

  //...

  AggregationsRepository::from([["keyword" => "metric-1", "value" => "ROUND(..."]]);

  //...
}
```

the `AggregationsRepository::from()` method accepts array of arrays or a Collection of arrays, and must have the following structure:

```
$metrics = [
  [
    "keyword" => "metric-1",
    "value" => "ROUND(..."
  ]
];
```

`keyword` is used to get the metric, and as the metric's alias in SQL, and the `value` defines the actual SQL that is inserted.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance73

Regular maintenance activity

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Recently: every ~16 days

Total

10

Last Release

37d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/66caa6fdec71c89ea1682dc96f90db0cf2a45adad9f1b34959553f0479290122?d=identicon)[byErikas](/maintainers/byErikas)

---

Top Contributors

[![byErikas](https://avatars.githubusercontent.com/u/55389436?v=4)](https://github.com/byErikas "byErikas (86 commits)")

---

Tags

bigqueryeloquentlaravellaraveleloquentbigquery

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/byerikas-eloquent-bigquery/health.svg)

```
[![Health](https://phpackages.com/badges/byerikas-eloquent-bigquery/health.svg)](https://phpackages.com/packages/byerikas-eloquent-bigquery)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11222.5M32](/packages/anourvalar-eloquent-serialize)[waad/laravel-model-metadata

A robust Laravel package for handling metadata with JSON casting, custom relation names, and advanced querying capabilities.

854.1k](/packages/waad-laravel-model-metadata)[mozex/laravel-scout-bulk-actions

Import, flush, and queue-import all your Laravel Scout searchable models at once. Auto-discovers models, runs in bulk, tracks progress.

1437.7k](/packages/mozex-laravel-scout-bulk-actions)[binafy/laravel-reactions

React to something in Laravel framework

875.6k](/packages/binafy-laravel-reactions)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2933.4k9](/packages/stayallive-laravel-eloquent-observable)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
