mongosoft/yii2-mongodate-behavior

MongoDate behavior for Yii 2

Installs: 109 941

Dependents: 2

Suggesters: 0

Security: 0

Stars: 6

Watchers: 2

Forks: 1

Type:yii2-extension

0.2.0 2016-07-08 13:21 UTC

This package is auto-updated.

Last update: 2024-12-12 18:23:06 UTC


README

MongoDateBehavior automatically fills the specified attributes with the current ISODate.

By default, MongoDateBehavior will fill the created and updated attributes with the current ISODate when the associated AR object is being inserted; it will fill the updated attribute with the ISODate when the AR object is being updated.

Latest Stable Version Total Downloads

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist mongosoft/yii2-mongodate-behavior "*"

or add

"mongosoft/yii2-mongodate-behavior": "*"

to the require section of your composer.json file.

Usage

Upload file

Attach the behavior in your model:

class User extends ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function collectionName()
    {
        return 'user';
    }

    /**
     * @inheritdoc
     */
    public function attributes()
    {
        return [
            '_id', 'name', 'created', 'updated',
        ];
    }

    /**
     * @inheritdoc
     */
    function behaviors()
    {
        return [
            MongoDateBehavior::className(),
        ];
    }
}