jaspaul/eloquent-sti
Composer 安装命令:
composer require jaspaul/eloquent-sti
包简介
A simple single table inheritance library for eloquent.
README 文档
README
Install
Via Composer
$ composer require jaspaul/eloquent-sti
Requirements
The following versions of PHP are supported by this version.
- PHP 7.2
- PHP 7.3
- PHP 7.4
Usage
<?php use Tests\Helpers\User; use Tests\Helpers\Administrator; use Jaspaul\EloquentSTI\Inheritable; use Illuminate\Database\Eloquent\Model; class User extends Model { use Inheritable; /** * Provides a map of types to resolve for this object. The format is: * 'user' => User::class, * 'administrator' => Administrator::class * * @var array */ protected $types = [ 'user' => User::class, 'administrator' => Administrator::class ]; }
<?php class Administrator extends User { }
Now when you select users through the User model, they'll be returned with the associated type. For instance if you have a record in the users table with the type administrator, an Administrator object will be returned when you run User::where('type', 'administrator')->first().
统计信息
- 总下载量: 6.74k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-19