PHPackages                             leko-team/laravel-active - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. leko-team/laravel-active

ActiveLibrary[Database &amp; ORM](/categories/database)

leko-team/laravel-active
========================

Ready-made solution for active an entity with Eloquent models

1.0.0(2y ago)41.3k↓66.7%MITPHP

Since Oct 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/leko-team/laravel-active)[ Packagist](https://packagist.org/packages/leko-team/laravel-active)[ RSS](/packages/leko-team-laravel-active/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Ready-made solution for active an entity with Eloquent models
=============================================================

[](#ready-made-solution-for-active-an-entity-with-eloquent-models)

[![Latest Version](https://camo.githubusercontent.com/79719c283d86cf1bfcba7ff2647c24214cafb3d4c31c8ea87ed269f64dbcd587/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6c656b6f2d7465616d2f6c61726176656c2d6163746976652e7376673f7374796c653d666c61742d737175617265)](https://github.com/leko-team/laravel-active/releases)

This package can activate entity with Eloquent models. It provides a simple API to work with.

Installation
------------

[](#installation)

The library can be installed via Composer:

```
composer require leko-team/laravel-active
```

Configuration
-------------

[](#configuration)

To be able active eloquent entities you need:

$table-&gt;boolean('is\_active')-&gt;default(false)-&gt;index()-&gt;comment('Признак активности'); $table-&gt;timestamp('start\_at')-&gt;nullable()-&gt;index()-&gt;comment('Временная метка начала активности'); $table-&gt;timestamp('end\_at')-&gt;nullable()-&gt;index()-&gt;comment('Временная метка окончания активности');

- Add migration with columns: `is_active`, `start_at`, `end_at`
- Or assign: `static::IS_ACTIVE`, `static::START_AT`, `static::END_AT` constant with the name of the column you want to use.

```
php artisan make:migration add_active_columns_in_`your-table`_table
```

```
    public function up(): void
    {
        Schema::table('your-table', function (Blueprint $table) {
            $table->boolean('is_active')->default(true)->index();
            $table->timestamp('start_at')->nullable()->index();
            $table->timestamp('end_at')->nullable()->index();
        });
    }

    public function down(): void
    {
        Schema::table('your-table', function (Blueprint $table) {
            $table->dropColumn('end_at');
            $table->dropColumn('start_at');
            $table->dropColumn('is_active');
        });
    }
```

If you have existing records in your table you maybe want to update them.

- Add trait `ActivityTrait` to your model.

```
use ActivityTrait;
```

Examples
--------

[](#examples)

### Base

[](#base)

To activate entity:

```
$review = Review::first();
$review->activate();
```

To deactivate entity:

```
$review = Review::first();
$review->deactivate();
```

### Scopes

[](#scopes)

By default from active entity return only active records with next condition: `Entity is true and start_at IS NULL OR = then current timestamp ('2023-10-23 13:52:37')`. You can change this by applying scope to your Eloquent model.

- withInactive

```
$review = Review::withInactive()->get();
```

Returns all records.

Credits
-------

[](#credits)

- A big thank you to [Laravel Package](https://www.laravelpackage.com/) for helping out build package with step by step guide.
- [Oleg Kolzhanov](https://github.com/oleg-kolzhanov) for helping with logic.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

985d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/01feaccb615ea8e12f99549ecd0c99256cf8a3c560e12606bebffd06236da8fc?d=identicon)[leko-team](/maintainers/leko-team)

---

Top Contributors

[![FenderTr](https://avatars.githubusercontent.com/u/52920728?v=4)](https://github.com/FenderTr "FenderTr (2 commits)")[![leko-team](https://avatars.githubusercontent.com/u/16772593?v=4)](https://github.com/leko-team "leko-team (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/leko-team-laravel-active/health.svg)

```
[![Health](https://phpackages.com/badges/leko-team-laravel-active/health.svg)](https://phpackages.com/packages/leko-team-laravel-active)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
