webbingbrasil/eloquent-sti

为Eloquent添加单表继承功能。

此包的官方仓库似乎已不存在,因此该包已被冻结。

1.0.0 2018-08-31 18:36 UTC

This package is auto-updated.

Last update: 2022-01-26 20:04:17 UTC


README

Eloquent STI 为Eloquent添加单表继承功能。

安装

composer require "webbingbrasil/eloquent-sti=1.0.0"

使用

在任何实体中使用CanBeInherited特质以在子实体中获取STI功能

use WebbingBrasil\EloquentSTI\CanBeInherited;

class User extends Model
{
    use CanBeInherited;
}

现在只需用任何子模型扩展父模型即可

class Admin extends User
{
}

class Manager extends User
{
}