PHPackages                             strtob/yii2-traits - 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. [Framework](/categories/framework)
4. /
5. strtob/yii2-traits

ActiveYii2-extension[Framework](/categories/framework)

strtob/yii2-traits
==================

Yii2 traits for yii2 models

09PHP

Since May 12Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/strtob/yii2-traits)[ Packagist](https://packagist.org/packages/strtob/yii2-traits)[ RSS](/packages/strtob-yii2-traits/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Yii2 Validity Trait
===================

[](#yii2-validity-trait)

A Yii2 trait for determining the validity stage of a date range based on two date properties: `valid_from` and `valid_until`. This trait categorizes the validity state into three stages and provides corresponding messages and Awesome icons.

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

[](#installation)

To include the `ValidityTrait` in your Yii2 project, you can either clone this repository or add it as a dependency in your `composer.json` file. Assuming you have Composer installed, you can run:

```
composer require strtob/yii2-traits
```

Example how to implement in Active Record class:

```
/**
 * This is the model class for table "tbl_department".
 */
class Department extends BaseDepartment
{

    use \strtob\yii2Traits\ValidityTrait;
```

Example of use as yii2 gridview column:

```
    [
            'attribute' => 'status',
            'label' => yii::t('app', 'Status'),
            'format' => 'raw',
            'value' => function ($model) {
                $v = $model->validityStage;

                $r = '';
                $r .= '';
                $r .= '';
                $r .= '';
                $r .= $v->message;
                $r .= '' . $v->relative_time . '';
                $r .= '';
                return $r;
            },
        ],
```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1cca3f4cf786146ef62da60fc8a21f94943c7da6d7cbfb453b3e1389390c8d2a?d=identicon)[strtob](/maintainers/strtob)

---

Top Contributors

[![strtob](https://avatars.githubusercontent.com/u/9219549?v=4)](https://github.com/strtob "strtob (7 commits)")

### Embed Badge

![Health badge](/badges/strtob-yii2-traits/health.svg)

```
[![Health](https://phpackages.com/badges/strtob-yii2-traits/health.svg)](https://phpackages.com/packages/strtob-yii2-traits)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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