PHPackages                             egorogl/laravel-db-blade - 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. egorogl/laravel-db-blade

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

egorogl/laravel-db-blade
========================

Render Blade templates from Eloquent Model Fields

v1.0.5(5y ago)031MITPHP ^7.2

Since Apr 17Compare

[ Source](https://github.com/egorogl/laravel-db-blade)[ Packagist](https://packagist.org/packages/egorogl/laravel-db-blade)[ RSS](/packages/egorogl-laravel-db-blade/feed)WikiDiscussions Synced 2d ago

READMEChangelogDependencies (2)Versions (9)Used By (0)

Laravel DB Blade
================

[](#laravel-db-blade)

[![Build Status](https://camo.githubusercontent.com/20e2dc6b86e2e87ca688fa4b1e6d8f47fd4f3de77800fca21be80215b2e84556/68747470733a2f2f7472617669732d63692e6f72672f6b69726f757368692f6c61726176656c2d64622d626c6164652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kiroushi/laravel-db-blade)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5e2a3ffda5483408506b74656f3511b0b5244becb129a853b5f360c28d7333af/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b69726f757368692f6c61726176656c2d64622d626c6164652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kiroushi/laravel-db-blade/?branch=master)

Render Blade templates from Eloquent Model Fields
-------------------------------------------------

[](#render-blade-templates-from-eloquent-model-fields)

This package allows you to render Blade templates from a database model instead of files. It is based on [Flynsarmy](https://github.com/Flynsarmy/)'s [**laravel-db-blade-compiler**](https://github.com/Flynsarmy/laravel-db-blade-compiler).

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

[](#installation)

You can install the package via composer:

```
composer require kiroushi/laravel-db-blade
```

Publish the assets using artisan:

```
php artisan vendor:publish
```

And then set up your DbView model in the `config/db-blade.php` configuration file. A default model (**Kiroushi\\DbBlade\\Models\\DbView**) is included in the package:

```
return [

    'model_name' => 'Kiroushi\DbBlade\Models\DbView',
    'table_name' => 'db_views',

    /**
     * The default name field used to look up for the model.
     * e.g. DbView::make($viewName) or dbview($viewName)
     */
    'name_field' => 'name',

    /**
     * The default model field to be compiled when not explicitly specified
     * with DbView::field($fieldName) or DbView::model($modelName, $fieldName)
     */
    'content_field' => 'content',

    /**
     * This property will be added to models being compiled with DbView
     * to keep track of which field in the model is being compiled
     */
    'model_property' => '__db_blade_compiler_content_field',

    'cache' => false,
    'cache_path' => 'app/db-blade/cache/views'

];
```

After the configuration and ensuring that the migration has been published, you can create the database views table by running the migrations:

```
php artisan migrate
```

Usage
-----

[](#usage)

This package offers a `DbView` facade with the exact same syntax and functionality than `View`:

```
return DbView::make('home')->with(['foo' => 'bar']);
```

You can also use the `dbview()` helper matching Laravel's base `view()` helper functionality. If no arguments are supplied, the factory is returned:

```
return dbview()->make('home')->with(['foo' => 'bar']);
```

If a string is supplied, a view with that name will be looked up for and rendered:

```
return dbview('home')->with(['foo' => 'bar']);
```

### Overriding settings at runtime

[](#overriding-settings-at-runtime)

You can override individual settings for the model, name field and content field by using associated methods:

```
return DbView::make('home')->model('App\Template');

return DbView::make('home')->field('template_name');

// You can also pass the model and name field as a shorthand:
return DbView::make('home')->model('App\Template', 'template_name');

// Override content field
return DbView::make('home')->contentField('template_content');

// ... or a combination of these
return DbView::make('home')->model('App\Template', 'template_name')->contentField('template_content');
```

### Cache

[](#cache)

By default, cache is disabled in config file. If you enable the setting, a compiled version of the views will be stored at the desired path. If the model is updated, the *updated\_at* field will be checked against the file modification date and the view will be re-rendered and cached.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

To do list
----------

[](#to-do-list)

- Expose view finder callback
- Separate standard view composers from dbview composers.
- Unit tests

License
-------

[](#license)

**laravel-db-blade** is open-sourced software licensed under the MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Recently: every ~124 days

Total

7

Last Release

2058d ago

Major Versions

0.1.0 → v1.0.02019-06-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/336408aa5be8a176e06e411c6d9b0f9916d62ba798de493e2f7719fdc3d3a657?d=identicon)[gogenzzo](/maintainers/gogenzzo)

---

Tags

laravelmodeleloquentbladecompiler

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/egorogl-laravel-db-blade/health.svg)

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

###  Alternatives

[flynsarmy/db-blade-compiler

Render Blade templates from Eloquent Model Fields

169876.0k2](/packages/flynsarmy-db-blade-compiler)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11222.5M33](/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)[akaunting/laravel-sortable

Sortable behavior package for Laravel

27189.9k](/packages/akaunting-laravel-sortable)

PHPackages © 2026

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