strtob/yii2-traits
Composer 安装命令:
composer require strtob/yii2-traits
包简介
Yii2 traits for yii2 models
README 文档
README
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
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 = '<div class="d-flex"><div>';
$r .= '<i class="' . $v->icon . ' me-2"></i>';
$r .= '</div>';
$r .= '<div>';
$r .= $v->message;
$r .= '<div><small>' . $v->relative_time . '</small></div>';
$r .= '</div></div>';
return $r;
},
],
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-17