PHPackages                             anthonyedmonds/laravel-db-views - 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. anthonyedmonds/laravel-db-views

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

anthonyedmonds/laravel-db-views
===============================

Manage database views for Laravel applications

1.1.0(1mo ago)082↓50%MITPHPPHP ^8

Since Feb 16Pushed 1mo agoCompare

[ Source](https://github.com/AnthonyEdmonds/laravel-db-views)[ Packagist](https://packagist.org/packages/anthonyedmonds/laravel-db-views)[ Docs](https://github.com/AnthonyEdmonds/laravel-db-views)[ RSS](/packages/anthonyedmonds-laravel-db-views/feed)WikiDiscussions main Synced 1mo ago

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

laravel-db-views
================

[](#laravel-db-views)

[![Composer status](.github/composer.svg)](.github/composer.svg)[![Coverage status](.github/coverage.svg)](.github/coverage.svg)[![NPM status](.github/npm.svg)](.github/npm.svg)[![PHP version](.github/php.svg)](.github/php.svg)[![Tests status](.github/tests.svg)](.github/tests.svg)

Manage database views for Laravel applications

Installation
------------

[](#installation)

Add this library using `composer require anthonyedmonds/laravel-db-views`.

The service provider will be automatically registered.

Publish the config file using `php artisan vendor:publish --tag=db-views"`

How does this work?
-------------------

[](#how-does-this-work)

You can define any number of Views by extending the `View` class provided in this library.

Register your `View` classes in the config file then run the `update:db-views` Artisan command to add them to your database.

Running the command will cause each registered View to be deleted and recreated fresh.

### Definition

[](#definition)

Each `View` consists of a name and a definition.

The name should be what you want the `View` to be called in the database, such as `my_requests_view`.

The definition should be an Eloquent or QueryBuilder query, which will have the needed view creation syntax prepended to it.

```
return DB::table('requests')
    ->select(...)
    ->leftJoin(...)
    ->where(...);
```

### Formatters

[](#formatters)

To assist with common column formatting tasks, some helpers have been provided in the `View` class:

MethodUsage`View::boolean($column, $as, $yes = 'Yes', $no = 'No', $null = $no)`Output a `boolean` column in "Yes", "No", "Null" format### Using database views with Eloquent scopes

[](#using-database-views-with-eloquent-scopes)

To limit results from a database view, you may wish to use an existing Eloquent scope.

A combination of `whereExists()` and `whereColumn()` will allow you to filter the result of a database view:

```
DB::table('my_view')
    ->whereExists(
        MyModel::query()
            ->forUser($user)
            ->whereColumn('my_view.id', '=', 'my_models.id'),
    )
    ->get();
```

### Testing

[](#testing)

If your database views are not populated during migration, add the `AssertsDatabaseViews` trait to your `TestCase` class to make the `useDatabaseViews()` method available wherever you need it.

```
protected function setUp(): void
{
    parent::setUp();

    $this->useDatabaseViews();
}
```

Configuration
-------------

[](#configuration)

### Views

[](#views)

Register the class-string of each View to be managed by the `update:db-views` command.

Help and support
----------------

[](#help-and-support)

You are welcome to raise any issues or questions on GitHub.

If you wish to contribute to this library, raise an issue before submitting a forked pull request.

Licence
-------

[](#licence)

Published under the MIT licence.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance90

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

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

Total

8

Last Release

50d ago

Major Versions

0.0.5 → 1.0.02026-02-17

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17785811?v=4)[Anthony Edmonds](/maintainers/AnthonyEdmonds)[@AnthonyEdmonds](https://github.com/AnthonyEdmonds)

---

Top Contributors

[![AnthonyEdmonds](https://avatars.githubusercontent.com/u/17785811?v=4)](https://github.com/AnthonyEdmonds "AnthonyEdmonds (19 commits)")

---

Tags

laraveldatabaseviews

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/anthonyedmonds-laravel-db-views/health.svg)

```
[![Health](https://phpackages.com/badges/anthonyedmonds-laravel-db-views/health.svg)](https://phpackages.com/packages/anthonyedmonds-laravel-db-views)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[spiritix/lada-cache

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

591444.8k2](/packages/spiritix-lada-cache)[pdphilip/elasticsearch

An Elasticsearch implementation of Laravel's Eloquent ORM

145360.2k4](/packages/pdphilip-elasticsearch)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

163166.8k](/packages/cybercog-laravel-clickhouse)[illuminatech/config

Provides support for Laravel application runtime configuration managed in persistent storage

14921.0k1](/packages/illuminatech-config)

PHPackages © 2026

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