yii2mod/yii2-behaviors
最新稳定版本:2.0
Composer 安装命令:
composer require yii2mod/yii2-behaviors
包简介
Collection of useful behaviors for Yii Framework 2.0
关键字:
README 文档
README
Collection of useful behaviors for Yii Framework 2.0
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yii2mod/yii2-behaviors "*"
or add
"yii2mod/yii2-behaviors": "*"
to the require section of your composer.json file.
Usage
- PurifyBehavior
public function behaviors() { return [ 'purify' => [ 'class' => PurifyBehavior::className(), 'attributes' => ['title', 'content'], 'config' => [ 'AutoFormat.Linkify' => true, 'HTML.TargetBlank' => true, 'HTML.Nofollow' => true ] ] ]; }
- CarbonBehavior
CarbonBehavior automatically creates a Carbon Instance for one or multiple attributes of an ActiveRecord object when
afterFindevent happen.
public function behaviors() { return [ 'carbon' => [ 'class' => CarbonBehavior::className(), 'attributes' => [ 'createdAt', 'trialEndAt', ] ], ]; } $user = UserModel::findOne(1); var_dump($user->createdAt->year); // 2016 var_dump($user->createdAt->month); // 5 var_dump($user->createdAt->day); // 10 // change date $user->trialEndAt->addYear(); $user->save();
Support us
Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.
统计信息
- 总下载量: 104.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 33
- 点击次数: 1
- 依赖项目数: 10
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-26