alish / activeable-model
随时激活或停用任何模型。
v0.1.0
2020-12-27 08:49 UTC
Requires
- php: ^7.4
- illuminate/database: ^8.0
- illuminate/support: ^8.0
Requires (Dev)
- orchestra/testbench: ^6.7
- phpunit/phpunit: ^9.3
README
使用此包,您可以为模型添加激活功能
安装
您可以通过composer安装此包
composer require alish/activeable-model
用法
要为模型添加激活行为,只需将IsActiveable
特质添加到模型中
use Alish\ActiveableModel\Tratis\IsActiveable; class Model { use IsActiveable; }
激活的默认行为已设置为true
,如果要让您的模型默认不激活
class Model { use IsActiveable; protected bool $defaultStatus = false; }
您可以通过以下方式访问模型的激活历史记录
$histories = $model->activeStates()->get(); // get the exact time of state change /** @var \Carbon\Carbon $changeStateTime */ $changeStateTime = $histories->first()->created_at; // you can also get the status of state change /** @var bool $status */ $status = $histories->first()->is_active;
您还可以发布迁移文件
php artisan vendor:publish --provider="Alish\ActiveableModel\ActiveableModelServiceProvider" --tag=migrations
测试
composer test
更新日志
有关最近更改的更多信息,请参阅更新日志。
贡献
有关详细信息,请参阅贡献指南。
安全
如果您发现任何与安全相关的问题,请通过alishabani9270@gmail.com发送电子邮件,而不是使用问题跟踪器。
鸣谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。
Laravel Package Boilerplate
此包是使用Laravel Package Boilerplate生成的。