PHPackages                             blasttech/laravel-where-plus - 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. blasttech/laravel-where-plus

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

blasttech/laravel-where-plus
============================

Extra where scopes for Laravel Eloquent

2.0.3(4y ago)125.3k1MITPHPPHP &gt;=7.2CI failing

Since Jan 16Pushed 4y ago9 watchersCompare

[ Source](https://github.com/blasttech/laravel-where-plus)[ Packagist](https://packagist.org/packages/blasttech/laravel-where-plus)[ Docs](https://github.com/blasttech/laravel-where-plus)[ RSS](/packages/blasttech-laravel-where-plus/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)Dependencies (3)Versions (22)Used By (0)

laravel-where-plus
==================

[](#laravel-where-plus)

Extra where scopes for Laravel Models

Functions:

- whereOrEmptyOrNull($column, $value, $ignore)
- whereInColumn($column, $value)
- whereNotInColumn($column, $value)
- whereIfNull($column, $ifNull, $operator = null, $value = null, $boolean = 'and')

whereOrEmptyOrNull
------------------

[](#whereoremptyornull)

This adds a where condition for when a $column should be equal to $value, but not equal to a $ignore

```
  $query->whereOrEmptyOrNull('Country', $input['country'], '');
```

If $input\['country'\] is not equal to '' then this will be the equivalent of:

```
  $query->where('Country', $input['country']);
```

Otherwise if $input\['country'\] === '' then a where statement isn't added.

Likewise, a default value could be added, eg.

```
$query->whereOrEmptyOrNull('Country', $input['country'], 'Australia');
```

If you wanted to only add a where statement when $input\['country'\] isn't 'Australia'.

This can also be run with an array of columns, e.g.:

```
  $query->whereOrEmptyOrNull([
          'Country' => $input['country'],
          'State' => $input['state'],
          'Locality' => $input['locality']
      ], '', '');
```

which would add where statements for Country, State and Locality if the input fields weren't empty.

whereInColumn
-------------

[](#whereincolumn)

This adds a where condition to only include records where $value is in $column. The value of $column should be a comma delimited list.

For example:

```
  $query->whereInColumn('Country', 'Australia');
```

In SQL, this would be the equivalent of:

```
  WHERE CONCAT(',', `Country`, ',') LIKE '%,Australia,%'
```

whereNotInColumn
----------------

[](#wherenotincolumn)

This adds a where condition to only include records where $value is not in $column. The value of $column should be a comma delimited list.

For example:

```
  $query->whereNotInColumn('Country', 'Australia');
```

In SQL, this would be the equivalent of:

```
  WHERE CONCAT(',', `Country`, ',') NOT LIKE '%,Australia,%'
```

whereIfNull($column, $ifNull, $operator = null, $value = null, $boolean = 'and')
--------------------------------------------------------------------------------

[](#whereifnullcolumn-ifnull-operator--null-value--null-boolean--and)

This adds a where condition with the column wrapped in an SQL 'IFNULL' with the column as the first parameter and $ifNull as the second parameter.

For example:

```
  $query->whereIfNull('Country', 'Australia', '=', 'New Zealand');
```

In SQL, this would be the equivalent of:

```
  WHERE IFNULL(`Country`, 'Australia') = 'New Zealand'
```

Aggregates
----------

[](#aggregates)

### Available scopes

[](#available-scopes)

- addCount
- addSum
- addAvg
- addMin
- addMax

### Example

[](#example)

```
Calls::make()
  ->select(['calltype'])
  ->addCount('id')
  ->addSum('seconds')
  ->addSum('seconds', 'seconds2')
  ->groupBy('calltype');
```

In SQL, this would be the equivalent of:

```
  select calltype, count(id), sum(seconds), sum(charge)
    from calls
   group by calltype
```

Group and Order
---------------

[](#group-and-order)

### Available scopes

[](#available-scopes-1)

- groupByIndex
- orderByIndex

### Example

[](#example-1)

```
Calls::make()
  ->select(['calltype', 'description'])
  ->addSum('charge')
  ->groupByIndex(1, 2);
  ->orderByIndex(1);
```

```
  select calltype, description, sum(charge)
    from calls
   group by 1, 2
   order by 1
```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~80 days

Recently: every ~215 days

Total

17

Last Release

1796d ago

Major Versions

0.1.14 → 2.0.02019-10-08

PHP version history (2 changes)0.1.0PHP &gt;=7.0

2.0.2PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4683976?v=4)[Michael Blair](/maintainers/mhkb)[@mhkb](https://github.com/mhkb)

---

Top Contributors

[![mhkb](https://avatars.githubusercontent.com/u/4683976?v=4)](https://github.com/mhkb "mhkb (29 commits)")[![ivanhennig](https://avatars.githubusercontent.com/u/6207878?v=4)](https://github.com/ivanhennig "ivanhennig (27 commits)")[![maikenunes](https://avatars.githubusercontent.com/u/4635672?v=4)](https://github.com/maikenunes "maikenunes (4 commits)")

---

Tags

laravelmodeleloquentwhere

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/blasttech-laravel-where-plus/health.svg)

```
[![Health](https://phpackages.com/badges/blasttech-laravel-where-plus/health.svg)](https://phpackages.com/packages/blasttech-laravel-where-plus)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M87](/packages/mongodb-laravel-mongodb)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k5.0M31](/packages/tucker-eric-eloquentfilter)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591452.8k2](/packages/spiritix-lada-cache)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[watson/validating

Eloquent model validating trait.

9733.4M53](/packages/watson-validating)

PHPackages © 2026

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