PHPackages                             phl/laravel-sti - 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. phl/laravel-sti

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

phl/laravel-sti
===============

Single table inheritance with eloquent

3.0.0(5y ago)173.1k[1 issues](https://github.com/paulhenri-l/laravel-sti/issues)MITPHPPHP ^7.3CI failing

Since Sep 29Pushed 5y agoCompare

[ Source](https://github.com/paulhenri-l/laravel-sti)[ Packagist](https://packagist.org/packages/phl/laravel-sti)[ RSS](/packages/phl-laravel-sti/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (8)Versions (7)Used By (0)

[![Travis](https://camo.githubusercontent.com/654fe281b42fda795d3c80d7287f38b50b41febe39b928dc6dccd6ad82d2f988/68747470733a2f2f6170692e7472617669732d63692e6f72672f7061756c68656e72692d6c2f6c61726176656c2d7374692e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/654fe281b42fda795d3c80d7287f38b50b41febe39b928dc6dccd6ad82d2f988/68747470733a2f2f6170692e7472617669732d63692e6f72672f7061756c68656e72692d6c2f6c61726176656c2d7374692e7376673f6272616e63683d6d6173746572)

Laravel STI
===========

[](#laravel-sti)

> This is my take at bringing Single Table Inheritance (STI) to the Eloquent ORM.

*This package can be used outside of a laravel app*

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

[](#installation)

```
composer require phl/laravel-sti

```

Usage
-----

[](#usage)

Besides using the trait and adding the type column there is nothing much to do.

```
class Member extends Illuminate\Database\Eloquent\Model
{
    use PHL\LaravelSTI\STI;
}
```

```
Schema::create('members', function ($table) {
    // ...
    $table->type();
    // ...
});
```

You can now extend the Member model.

```
class PremiumMember extends Member
{
    //
}

class RegularMember extends Member
{
    //
}
```

And enjoy single table inheritance!

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

[](#configuration)

Out of the box there is absolutely nothing to configure. You may want to change the defaults though.

### Type column

[](#type-column)

By default the type column is named `type` if you want to use another name you can specify it in the migration and in the model.

```
class Member extends Illuminate\Database\Eloquent\Model
{
    use PHL\LaravelSTI\STI;

    protected static $stiTypeKey = 'custom_type_column'
}
```

```
Capsule::schema()->create('members', function ($table) {
    // ...
    $table->type('custom_type_column');
    // ...
});
```

### Type value

[](#type-value)

If you do not want your type column to contain the class name you can use Eloquent's `Relation::morphMap()` function to add mapping between a name and a class.

```
Relation::morphMap([
    'regular_member' => RegularMember::class,
]);
```

Now the type column will be filled with `regular_member` instead of `Member`. This helps avoid leaking code details into the DB.

Read the source Luke!
---------------------

[](#read-the-source-luke)

If you are currious about the implementation details, the code and tests have been heavily documented :)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

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

Recently: every ~172 days

Total

6

Last Release

2102d ago

Major Versions

1.0.1 → 2.02019-02-26

2.2.0 → 3.0.02020-09-27

PHP version history (4 changes)1.0PHP ^7.1

2.1PHP ^7.2

2.2.0PHP ^7.2.5

3.0.0PHP ^7.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25308170?v=4)[Paul-Henri Leobon](/maintainers/paulhenri-l)[@paulhenri-l](https://github.com/paulhenri-l)

---

Top Contributors

[![paulhenri-l](https://avatars.githubusercontent.com/u/25308170?v=4)](https://github.com/paulhenri-l "paulhenri-l (33 commits)")

---

Tags

eloquentlaravelsingle-table-inheritance

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phl-laravel-sti/health.svg)

```
[![Health](https://phpackages.com/badges/phl-laravel-sti/health.svg)](https://phpackages.com/packages/phl-laravel-sti)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M88](/packages/mongodb-laravel-mongodb)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[watson/validating

Eloquent model validating trait.

9733.4M53](/packages/watson-validating)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4833.0M9](/packages/dyrynda-laravel-model-uuid)[ryangjchandler/orbit

A flat-file database driver for Eloquent.

929269.2k5](/packages/ryangjchandler-orbit)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45344.0k1](/packages/pressbooks-pressbooks)

PHPackages © 2026

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