PHPackages                             snetty/laravel-calculated-columns - 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. snetty/laravel-calculated-columns

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

snetty/laravel-calculated-columns
=================================

Create calculated columns for laravel models

017PHP

Since Feb 12Pushed 10y agoCompare

[ Source](https://github.com/snetty/laravel-calculated-columns)[ Packagist](https://packagist.org/packages/snetty/laravel-calculated-columns)[ RSS](/packages/snetty-laravel-calculated-columns/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Calculated Columns
==========================

[](#laravel-calculated-columns)

An simple way to add calculated columns to your eloquent models

Usage
-----

[](#usage)

1. `composer require snetty/laravel-calculated-columns`
2. add the trait `Snetty\LaravelCalculatedColumns\CalculatedColumns;` to your models
3. declare your calculated columns in the form `protected $calculated_columns = ['new_column_name' => '(SELECT "SOME SUB QUERY")'];`
4. You can use `:user_id` in your subqueries and it will be parsed in automatically. If no user is present, the *whole subquery will return false*
5. you can now treat the column in eloquent as if it were a physical column

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1765472?v=4)[Simon Stevens](/maintainers/snetty)[@snetty](https://github.com/snetty)

### Embed Badge

![Health badge](/badges/snetty-laravel-calculated-columns/health.svg)

```
[![Health](https://phpackages.com/badges/snetty-laravel-calculated-columns/health.svg)](https://phpackages.com/packages/snetty-laravel-calculated-columns)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8441.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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