PHPackages                             oldtimeguitarguy/eloquent-single-table-inheritance - 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. oldtimeguitarguy/eloquent-single-table-inheritance

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

oldtimeguitarguy/eloquent-single-table-inheritance
==================================================

Simple single table inheritance for eloquent models in Laravel &amp; Lumen

v1.0.8(9y ago)15.1k↓100%MITPHP

Since Jul 9Pushed 9y agoCompare

[ Source](https://github.com/oldtimeguitarguy/eloquent-single-table-inheritance)[ Packagist](https://packagist.org/packages/oldtimeguitarguy/eloquent-single-table-inheritance)[ RSS](/packages/oldtimeguitarguy-eloquent-single-table-inheritance/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)DependenciesVersions (10)Used By (0)

Eloquent Single Table Inheritance
=================================

[](#eloquent-single-table-inheritance)

This is a very simple implementation of single table inheritance for Eloquent (Laravel &amp; Lumen).

There are no attribute restrictions or anything that could be considered robust. There are other libraries that do those things quite well.

This simply allows you to have a single table that, when fetched, is thrown into an Eloquent model of your choice, defined by a column in that table (typically "type", which is the default keyed type column. You can customize this).

For instance, imagine you have the following table (called `people`):

idnamesex1Fredboy2Jillgirl... and imagine you had the following classes:

```
class Person extends StiParent
{
    protected $table = 'people';
    protected static $stiKey = 'sex';
    protected static $stiChildren = [
        'boy' => Boy::class,
        'girl' => Girl::class,
    ];
}

class Boy extends Person
{
    //
}

class Girl extends Person
{
    //
}
```

When you fetch all people, you will get a mix of boys &amp; girls in the collection.

When you fetch just boys, you will get just boys.

When you fetch just girls, you will get just girls.

UNFORTUNATELY
-------------

[](#unfortunately)

1. You cannot make your `Person` class abstract.
2. You must specify the table on the parent
3. When creating a `hasMany` association, you must make sure you specify the foreign key. Otherwise, it will try to automatically generate one from the class name.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity69

Established project with proven stability

 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

9

Last Release

3557d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/71b10d228fd9de25aebbdd68dd046f30891b73db996198131160d4e20555105c?d=identicon)[oldtimeguitarguy](/maintainers/oldtimeguitarguy)

---

Top Contributors

[![karlhepler](https://avatars.githubusercontent.com/u/791071?v=4)](https://github.com/karlhepler "karlhepler (1 commits)")

---

Tags

eloquentlaravellumensingle-table

### Embed Badge

![Health badge](/badges/oldtimeguitarguy-eloquent-single-table-inheritance/health.svg)

```
[![Health](https://phpackages.com/badges/oldtimeguitarguy-eloquent-single-table-inheritance/health.svg)](https://phpackages.com/packages/oldtimeguitarguy-eloquent-single-table-inheritance)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

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

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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