Skip to content

Commit c65491b

Browse files
fix translations and migrations
1 parent c9ac986 commit c65491b

7 files changed

+27
-15
lines changed

migrations/m240111_115911_create_users_table.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function up()
2424
'birthday' => $this->dateTime()->defaultValue(null),
2525
'status' => $this->integer()->defaultValue(10),
2626
'sex' => $this->integer()->defaultValue(0),
27-
'created_at' => $this->dateTime()->defaultValue( new \yii\db\Expression('CURRENT_TIMESTAMP') ),
27+
'created_at' => $this->timestamp()->defaultValue( new \yii\db\Expression('CURRENT_TIMESTAMP') ),
2828
'updated_at' => $this->dateTime()
2929
]
3030
);

migrations/m240111_185911_create_roles_table.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function up()
1616
'title' => $this->string(255)->notNull(),
1717
'code' => $this->string(255)->notNull(),
1818
'description' => $this->text(),
19-
'created_at' => $this->dateTime()->defaultValue( new \yii\db\Expression('NOW()') ),
19+
'created_at' => $this->timestamp()->defaultValue( new \yii\db\Expression('CURRENT_TIMESTAMP') ),
2020
]
2121
);
2222

migrations/m240112_191311_create_user_roles_table.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function up()
1616
'user_id' => $this->integer(),
1717
'role_id' => $this->integer(),
1818
'note' => $this->string(500),
19-
'created_at' => $this->dateTime()->defaultValue( new \yii\db\Expression('NOW()') ),
19+
'created_at' => $this->timestamp()->defaultValue( new \yii\db\Expression('CURRENT_TIMESTAMP') ),
2020
]
2121
);
2222

src/messages/ru/user.php

+5
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@
3030
'Role' => 'Роль',
3131
'Roles' => 'Роли',
3232
'Create Roles' => 'Создать роль',
33+
'Add role' => 'Добавить роль',
34+
'Delete role' => 'Удалить роль',
3335
//users
3436
'Username' => 'Логин',
3537
'Users' => 'Пользователи',
3638
'This email is already taken!' => 'Этот Email уже занят!',
3739
'Login' => 'Логин',
3840
'City' => 'Город',
3941
'Avatar' => 'Аватар',
42+
'Deleted' => 'Удален',
4043
'User' => 'Пользователь',
4144
'Manager' => 'Менеджер',
4245
'Senior manager' => 'Старший менеджер',
@@ -51,7 +54,9 @@
5154
'Female' => 'Женский',
5255
'You cannot give a user a status higher than or equal to yours!' => 'Нельзя ставить пользователю статус выше или равный вашему!',
5356
// actions
57+
'Create User' => 'Создать пользователя',
5458
'Save' => 'Сохранить',
59+
'Update' => 'Изменить',
5560

5661
//
5762
'Hello' => 'Здравствуйте',

src/views/user/_form.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use yii\helpers\Html;
44
use yii\widgets\ActiveForm;
55
use app\models\User;
6+
use ZakharovAndrew\user\Module;
67

78
/** @var yii\web\View $this */
89
/** @var app\models\User $model */
@@ -30,7 +31,7 @@
3031
<?= $form->field($model, 'sex')->dropDownList(User::getSexList()) ?>
3132

3233
<div class="form-group">
33-
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
34+
<?= Html::submitButton(Module::t('Save'), ['class' => 'btn btn-success']) ?>
3435
</div>
3536

3637
<?php ActiveForm::end(); ?>

src/views/user/index.php

+14-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<h1><?= Html::encode($this->title) ?></h1>
2121

2222
<p>
23-
<?= Html::a('Create User', ['create'], ['class' => 'btn btn-success']) ?>
23+
<?= Html::a(Module::t('Create User'), ['create'], ['class' => 'btn btn-success']) ?>
2424
</p>
2525

2626
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
@@ -33,14 +33,21 @@
3333

3434
'id',
3535
'username',
36-
//'auth_key',
37-
//'password',
36+
3837
//'password_reset_token',
39-
//'email:email',
4038
'name',
39+
'email:email',
4140
//'avatar',
4241
//'city',
4342
//'birthday',
43+
[
44+
'attribute' => 'sex',
45+
'format' => 'raw',
46+
'filter' => User::getSexList(),
47+
'value' => function ($model) {
48+
return User::getSexList()[$model->sex] ?? '';
49+
}
50+
],
4451
[
4552
'attribute' => 'status',
4653
'format' => 'raw',
@@ -58,17 +65,16 @@
5865
$roles = UserRoles::getUserRoles($model->id);
5966

6067
foreach ($roles as $role) {
61-
$result .= $role->title . '<a href="'.Url::toRoute(['/user/user-roles/delete', 'id' => $role->id]).'" title="Delete" aria-label="Delete" >X</a>';
68+
$result .= $role->title . '<a href="'.Url::toRoute(['/user/user-roles/delete', 'id' => $role->id]).'" title="'.Module::t('Delete role').'" aria-label="'.Module::t('Delete role').'" >X</a>';
6269
}
6370

64-
$result .= '<a href="'.Url::toRoute(['/user/user-roles/create', 'user_id' => $model->id, 'form'=>'_form_good_product']).'" title="Delete" aria-label="Delete" class="btn btn-sm btn-success">+</a>';
71+
$result .= '<a href="'.Url::toRoute(['/user/user-roles/create', 'user_id' => $model->id, 'form'=>'_form_good_product']).'" title="'.Module::t('Add role').'" aria-label="'.Module::t('Add role').'" class="btn btn-sm btn-success">+</a>';
6572

6673
return $result;
6774

6875
}
6976
],
70-
//'sex',
71-
//'shop_id',
77+
7278
//'created_at',
7379
//'updated_at',
7480

src/views/user/update.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

33
use yii\helpers\Html;
4+
use ZakharovAndrew\user\Module;
45

56
/** @var yii\web\View $this */
67
/** @var app\models\User $model */
78

89
$this->title = 'Update User: ' . $model->id;
9-
$this->params['breadcrumbs'][] = ['label' => 'Users', 'url' => ['index']];
10-
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
11-
$this->params['breadcrumbs'][] = 'Update';
10+
$this->params['breadcrumbs'][] = ['label' => Module::t('Users'), 'url' => ['index']];
11+
$this->params['breadcrumbs'][] = Module::t('Update');
1212
?>
1313
<div class="user-update">
1414

0 commit comments

Comments
 (0)