alish/activeable-model

activate or deactivate any model any time on demand.

v0.1.0 2020-12-27 08:49 UTC

This package is auto-updated.

Last update: 2024-09-27 17:48:30 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

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.