igaster/eloquent-inheritance
Larablocks Analysis
igaster/eloquent-inheritance works with Laravel 5 (latest release v1.0.1, Jan 17, 2016), which reached end of life: no more fixes, even for security.
Recommendation checks
Use with careUse with care: meets 0 of 4 checks.
- Supports only Laravel 5, past end of life
- No release in the last 12 months (last: Jan 17, 2016)
- 0 downloads a month (needs 10,000)
- 5 GitHub stars (needs 100)
State
Quiet- Last stable release: Jan 17, 2016.
- No releases in the last 12 months.
- First released: Jan 5, 2016.
- 0 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Nov 27, 2026.
| Install | |
|---|---|
composer require igaster/eloquent-inheritance |
|
| Latest Version: | v1.0.1 |
| PHP: | >=5.4.0 |
| Laravel: | 5 |
| License: | MIT |
| Last Updated: | May 26, 2026 |
| Links: | GitHub · Packagist |
Description
Eloquent Multiple Table Inheritance: Use a One-To-One (or One-To-Many) relation between a parent & child Tables to simulate inheritance between Models.
Installation:
Edit your project's composer.json file to require:
"require": {
"igaster/eloquent-inheritance": "~1.0"
}
and install with composer update
Usage:
Example Schema:
// Model Foo is the parent model
Schema::create('foo', function (Blueprint $table) {
$table->increments('id');
$table->integer('a');
});
// Model Bar inherits Foo.
Schema::create('bar', function (Blueprint $table) {
$table->increments('id');
$table->integer('b');
$table->integer('foo_id')->nullable(); // Foreign Key to Foo
});
Example Models:
Your models should use the EloquentInherited Trait
class Foo extends Eloquent
{
use \igaster\EloquentInheritance\EloquentInherited;
// ...
public function fooMethod(){}
}
class Bar extends Eloquent
{
use \igaster\EloquentInheritance\EloquentInherited;
// ...
public function barMethod(){}
}
class BarExtendsFoo extends igaster\EloquentInheritance\InheritsEloquent{
// Set Parent/Child classes
public static $parentClass = Foo::class;
public static $childClass = Bar::class;
// You must declare Parent/Child keys explicity:
public static $parentKeys = ['id','a'];
public static $childKeys = ['id','b','foo_id'];
// Childs Foreign Key (points to Parent)
public static $childFK = 'foo_id';
// You can add your functions / variables ...
public function newMethod(){}
}
Usage:
// Create a composite Model:
$fooBar = BarExtendsFoo::create([ // Creates and Saves Foo & Bar in the Database
'a' => 1,
'b' => 2,
]);
// Access Attributes:
$fooBar->a; // = 1 (from Foo model)
$fooBar->b; // = 2 (from Bar model)
// Call Methods:
$fooBar->fooMethod(); // from Foo Model
$fooBar->barMethod(); // from Bar Model
$fooBar->newMethod(); // from self
// Query as an Eloquent model:
$fooBar = BarExtendsFoo::find(1);
$fooBar = BarExtendsFoo::where('a',1)->first();
$fooBar = BarExtendsFoo::get(); // Collection of BarExtendsFoo
$fooBar->save(); // Saves Foo & Bar
$fooBar->delete(); // Deletes Foo & Bar
$fooBar->update([ // Updates Foo & Bar
'a' => 10,
'b' => 20,
]);
Related Packages
A simple Trait that implements the Decorator pattern on Laravel eloquent models.
Enchace your models to produce different versions of any image (eg for thumbnail...
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.0.1 | >=5.4.0 | 5.* | MIT | |
| v1.0.0 | >=5.4.0 | 5.* | MIT |