承接 ruskid/yii2-ip-behavior 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ruskid/yii2-ip-behavior

Composer 安装命令:

composer require ruskid/yii2-ip-behavior

包简介

Yii2 Behavior that records User IP address on Updates/Inserts

README 文档

README

Yii2 Behavior that records User IP address on Updates/Inserts

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require ruskid/yii2-ip-behavior "dev-master"

or add

"ruskid/yii2-ip-behavior": "dev-master"

to the require section of your composer.json file.

Or

I wanted to test the composer xd. You can just copy paste IpBehavior.php to behaviors folder or any folder you like. (just don't forget to change the namespace).

Usage

You can call it like this.

public function behaviors() {
        return [
            ...
            'ip' => [
                'class' => IpBehavior::className(),
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_ip', 'updated_ip'],
                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_ip',
                ],
            ]
            ...
        ];
    }

Or like this. where value can be a string or an anonymous function that will return a string.

public function behaviors() {
        return [
            ...
            'ip' => [
                'class' => IpBehavior::className(),
                'createdIpAttribute' => 'created_ip',
                'updatedIpAttribute' => 'updated_ip',
                'value' => '127.0.0.1',
            ]
            ...
        ];
    }

Extras

this will set user's IP address to the attribute of the model.

$user->setIp('updated_ip');

统计信息

  • 总下载量: 10.05k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3
  • 更新时间: 2014-11-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固