|
| 1 | +### Gii |
| 2 | + |
| 3 | +目录 |
| 4 | + |
| 5 | +- Model |
| 6 | +- CURD |
| 7 | + |
| 8 | +使用条件 |
| 9 | + |
| 10 | +- 开发模式 |
| 11 | +- rageframe 版本号 >= 2.3.94 |
| 12 | +- backend/gii |
| 13 | + |
| 14 | +### Model |
| 15 | + |
| 16 | +- 表字段已经备注 |
| 17 | +- Code Template 选择 rageframe |
| 18 | + |
| 19 | +那么你选择一个表进行生成 Model 你会发现 attributeLabels 全部替换成为字段备注,不用再重新修改 |
| 20 | + |
| 21 | +``` |
| 22 | +<?php |
| 23 | +
|
| 24 | +namespace app\models; |
| 25 | +
|
| 26 | +use Yii; |
| 27 | +
|
| 28 | +/** |
| 29 | + * This is the model class for table "{{%addon_article_adv}}". |
| 30 | + * |
| 31 | + * @property int $id 序号 |
| 32 | + * @property string $merchant_id 商户id |
| 33 | + * @property string $title 标题 |
| 34 | + * @property string $cover 图片 |
| 35 | + * @property int $location_id 广告位ID |
| 36 | + * @property string $silder_text 图片描述 |
| 37 | + * @property int $start_time 开始时间 |
| 38 | + * @property int $end_time 结束时间 |
| 39 | + * @property string $jump_link 跳转链接 |
| 40 | + * @property int $jump_type 跳转方式[1:新标签; 2:当前页] |
| 41 | + * @property int $sort 优先级 |
| 42 | + * @property int $status 状态 |
| 43 | + * @property string $created_at 创建时间 |
| 44 | + * @property string $updated_at 更新时间 |
| 45 | + */ |
| 46 | +class AddonArticleAdv extends \yii\db\ActiveRecord |
| 47 | +{ |
| 48 | + /** |
| 49 | + * {@inheritdoc} |
| 50 | + */ |
| 51 | + public static function tableName() |
| 52 | + { |
| 53 | + return '{{%addon_article_adv}}'; |
| 54 | + } |
| 55 | +
|
| 56 | + /** |
| 57 | + * {@inheritdoc} |
| 58 | + */ |
| 59 | + public function rules() |
| 60 | + { |
| 61 | + return [ |
| 62 | + [['merchant_id', 'location_id', 'start_time', 'end_time', 'jump_type', 'sort', 'status', 'created_at', 'updated_at'], 'integer'], |
| 63 | + [['title'], 'string', 'max' => 30], |
| 64 | + [['cover'], 'string', 'max' => 100], |
| 65 | + [['silder_text', 'jump_link'], 'string', 'max' => 150], |
| 66 | + ]; |
| 67 | + } |
| 68 | +
|
| 69 | + /** |
| 70 | + * {@inheritdoc} |
| 71 | + */ |
| 72 | + public function attributeLabels() |
| 73 | + { |
| 74 | + return [ |
| 75 | + 'id' => '序号', |
| 76 | + 'merchant_id' => '商户id', |
| 77 | + 'title' => '标题', |
| 78 | + 'cover' => '图片', |
| 79 | + 'location_id' => '广告位ID', |
| 80 | + 'silder_text' => '图片描述', |
| 81 | + 'start_time' => '开始时间', |
| 82 | + 'end_time' => '结束时间', |
| 83 | + 'jump_link' => '跳转链接', |
| 84 | + 'jump_type' => '跳转方式[1:新标签; 2:当前页]', |
| 85 | + 'sort' => '优先级', |
| 86 | + 'status' => '状态', |
| 87 | + 'created_at' => '创建时间', |
| 88 | + 'updated_at' => '更新时间', |
| 89 | + ]; |
| 90 | + } |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +### CURD |
| 95 | + |
| 96 | +1、设置好模型路径(注意是已经创建好的Model),选择生成控制器命名空间和视图文件路径,选择模板为 rageframe 即可进行生成预览 |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | +2、 勾选你首页需要显示的字段和编辑页面需要显示的字段和控件类型即可直接生成一个定制化的 CURD |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | +3、选择后点击预览,没有问题了可直接点击创建进行生成 |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | +4、访问对应的路径进行查看,这样子关于页面显示、查询、编辑就完成了,就那么简单 |
| 109 | + |
| 110 | + |
0 commit comments