alish / activeable-model
activate or deactivate any model any time on demand.
Requires
- php: ^7.4
- illuminate/database: ^8.0
- illuminate/support: ^8.0
Requires (Dev)
- orchestra/testbench: ^6.7
- phpunit/phpunit: ^9.3
README
with this package you can add activation ability to your models
Installation
You can install the package via composer:
composer require alish/activeable-model
Usage
for adding activation behavior to your model just use IsActiveable
trait to your model
use Alish\ActiveableModel\Tratis\IsActiveable; class Model { use IsActiveable; }
the default behavior of activation has been set to true
,if you want that your models became deactive by default:
class Model { use IsActiveable; protected bool $defaultStatus = false; }
you have access to history of activation of your model with
$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;
you can also publish the migration file:
php artisan vendor:publish --provider="Alish\ActiveableModel\ActiveableModelServiceProvider" --tag=migrations
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email alishabani9270@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.