PHPackages                             zanysoft/virtualcolumn - 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. zanysoft/virtualcolumn

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

zanysoft/virtualcolumn
======================

Laravel - Eloquent virtual column.

1.0.1(1y ago)06MITPHP

Since Feb 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/zanysoft/virtualcolumn)[ Packagist](https://packagist.org/packages/zanysoft/virtualcolumn)[ RSS](/packages/zanysoft-virtualcolumn/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Laravel - Eloquent Virtual Column
=================================

[](#laravel---eloquent-virtual-column)

> Save additional data to virtual column

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

[](#installation)

```
composer require zanysoft/virtualcolumn

```

Usage
-----

[](#usage)

Use the `VirtualColumn` trait on your model:

```
use Illuminate\Database\Eloquent\Model;
use ZanySoft\VirtualColumn\VirtualColumn;

class MyModel extends Model
{
    use VirtualColumn;

    public $guarded = [];
}
```

For custom virtual column where you want to save additional data. Default column name is `data`

```
use Illuminate\Database\Eloquent\Model;
use ZanySoft\VirtualColumn\VirtualColumn;

class MyModel extends Model
{
    use VirtualColumn;

    public static function getDataColumn(): string
    {
        return 'data'; //name of the column that stores additional data.
    }
}
```

For saving data to existing database columns, by default all columns from the table are selected, except virtual column.

```
use Illuminate\Database\Eloquent\Model;
use ZanySoft\VirtualColumn\VirtualColumn;

class MyModel extends Model
{
    use VirtualColumn;

    public static function getCustomColumns(): array
    {
        return [
            'id',
            'custom1',
            'custom2',
        ];
    }
}
```

Create a migration:

```
public function up()
{
    Schema::create('my_models', function (Blueprint $table) {
        $table->increments('id');

        $table->string('custom1')->nullable();
        $table->string('custom2')->nullable();

        $table->json('data');
    });
}
```

And store any data on your model:

```
$myModel = MyModel::create(['custom1' => 'custom 1', 'custom2' => 'custom 2', 'foo' => 'bar']);
$myModel->update(['custom1' => 'custom 1', 'custom2' => 'custom 2', 'foo' => 'bar']);
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance43

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

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

Unknown

Total

1

Last Release

454d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77060551?v=4)[Mubashar Ahmad (مبشر احمد)](/maintainers/mubasharahmad)[@MubasharAhmad](https://github.com/MubasharAhmad)

---

Tags

datalaravelvirtual-columnlaraveldatacolumnvirtualvirtualcolumnvirtual-column

### Embed Badge

![Health badge](/badges/zanysoft-virtualcolumn/health.svg)

```
[![Health](https://phpackages.com/badges/zanysoft-virtualcolumn/health.svg)](https://phpackages.com/packages/zanysoft-virtualcolumn)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8703.0M17](/packages/yajra-laravel-oci8)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)

PHPackages © 2026

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