cities for profiles

This commit is contained in:
Leorne 2019-12-09 10:54:39 +03:00
parent 86b5476998
commit 8200544531
7 changed files with 60 additions and 7 deletions

View File

@ -21,7 +21,7 @@ class UserCardSearch extends UserCard
{ {
return [ return [
[['id', 'gender', 'status'], 'integer'], [['id', 'gender', 'status'], 'integer'],
[['fio', 'passport', 'photo', 'email', 'dob', 'created_at', 'updated_at'], 'safe'], [['fio', 'passport', 'photo', 'email', 'dob', 'created_at', 'updated_at', 'city'], 'safe'],
['skills', 'each', 'rule' => ['integer']], ['skills', 'each', 'rule' => ['integer']],
]; ];
} }
@ -71,6 +71,7 @@ class UserCardSearch extends UserCard
'gender' => $this->gender, 'gender' => $this->gender,
'dob' => $this->dob, 'dob' => $this->dob,
'status' => $this->status, 'status' => $this->status,
'city' => $this->city,
'created_at' => $this->created_at, 'created_at' => $this->created_at,
'updated_at' => $this->updated_at, 'updated_at' => $this->updated_at,
]); ]);
@ -78,6 +79,7 @@ class UserCardSearch extends UserCard
$query->andFilterWhere(['like', 'fio', $this->fio]) $query->andFilterWhere(['like', 'fio', $this->fio])
->andFilterWhere(['like', 'passport', $this->passport]) ->andFilterWhere(['like', 'passport', $this->passport])
->andFilterWhere(['like', 'photo', $this->photo]) ->andFilterWhere(['like', 'photo', $this->photo])
->andFilterWhere(['like', 'city', $this->city])
->andFilterWhere(['like', 'email', $this->email]); ->andFilterWhere(['like', 'email', $this->email]);
$query->andFilterWhere(['skill.id' => $this->skills]); $query->andFilterWhere(['skill.id' => $this->skills]);

View File

@ -67,6 +67,12 @@ use yii\widgets\ActiveForm;
</div> </div>
</div> </div>
<div class="row">
<div class="col-xs-6">
<?= $form->field($model, 'city')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-xs-6"> <div class="col-xs-6">
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>

View File

@ -36,6 +36,7 @@ $this->params['breadcrumbs'][] = $this->title;
}, },
], ],
'fio', 'fio',
// 'city',
//'passport', //'passport',
'salary', 'salary',
'email:email', 'email:email',

View File

@ -6,9 +6,9 @@ use yii\helpers\Html;
/* @var $model backend\modules\card\models\UserCard */ /* @var $model backend\modules\card\models\UserCard */
$this->title = $model->fio; $this->title = $model->fio;
$this->params['breadcrumbs'][] = ['label' => 'User Cards', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => 'Профили', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update'; $this->params['breadcrumbs'][] = 'Редактировать';
?> ?>
<div class="user-card-update"> <div class="user-card-update">

View File

@ -12,12 +12,13 @@ use yii\widgets\DetailView;
/* @var $modelFildValue yii\data\ActiveDataProvider */ /* @var $modelFildValue yii\data\ActiveDataProvider */
$this->title = $model->fio; $this->title = $model->fio;
$this->params['breadcrumbs'][] = ['label' => 'User Cards', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => 'Профили', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="user-card-view"> <div class="user-card-view">
<p> <p>
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> <?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
</p> </p>
@ -27,19 +28,23 @@ $this->params['breadcrumbs'][] = $this->title;
'fio', 'fio',
'passport', 'passport',
[ [
'attribute' => 'Photo', 'attribute' => 'photo',
'format' => 'raw', 'format' => 'raw',
'value' => function ($model) { 'value' => function ($model) {
return Html::tag('img', null, ['src' => $model->photo, 'width' => '100px']); return Html::tag('img', null, ['src' => $model->photo, 'width' => '100px']);
} }
], ],
[ [
'attribute' => 'Resume', 'attribute' => 'resume',
'format' => 'raw', 'format' => 'raw',
'value' => function ($model) { 'value' => function ($model) {
return Html::a('Скачать', $model->resume, ['target' => '_blank']); return Html::a('Скачать', $model->resume, ['target' => '_blank']);
} }
], ],
[
'attribute' => 'city',
'value' => $model->city
],
[ [
'attribute' => 'gender', 'attribute' => 'gender',
'value' => $model->gendersText, 'value' => $model->gendersText,

View File

@ -26,6 +26,7 @@ use yii\helpers\ArrayHelper;
* @property string $resume * @property string $resume
* @property string $salary * @property string $salary
* @property int $position_id * @property int $position_id
* @property int $city
* *
* @property FieldsValue[] $fieldsValues * @property FieldsValue[] $fieldsValues
* @property ProjectUser[] $projectUsers * @property ProjectUser[] $projectUsers
@ -66,7 +67,7 @@ class UserCard extends \yii\db\ActiveRecord
[['fio', 'status', 'gender'], 'required'], [['fio', 'status', 'gender'], 'required'],
[['gender', 'status', 'position_id', 'id_user'], 'integer'], [['gender', 'status', 'position_id', 'id_user'], 'integer'],
[['dob', 'created_at', 'updated_at', 'deleted_at'], 'safe'], [['dob', 'created_at', 'updated_at', 'deleted_at'], 'safe'],
[['fio', 'passport', 'photo', 'email', 'resume'], 'string', 'max' => 255], [['fio', 'passport', 'photo', 'email', 'resume', 'city'], 'string', 'max' => 255],
[['salary'], 'string', 'max' => 100], [['salary'], 'string', 'max' => 100],
[['position_id'], 'exist', 'skipOnError' => true, 'targetClass' => Position::class, 'targetAttribute' => ['position_id' => 'id']], [['position_id'], 'exist', 'skipOnError' => true, 'targetClass' => Position::class, 'targetAttribute' => ['position_id' => 'id']],
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']], [['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],
@ -94,6 +95,7 @@ class UserCard extends \yii\db\ActiveRecord
'resume' => 'Резюме', 'resume' => 'Резюме',
'salary' => 'Зарплата', 'salary' => 'Зарплата',
'position_id' => 'Должность', 'position_id' => 'Должность',
'city' => 'Город',
]; ];
} }

View File

@ -0,0 +1,37 @@
<?php
use yii\db\Migration;
/**
* Class m191206_145411_add_column_city_to_user_card
*/
class m191206_145411_add_column_city_to_user_card extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('user_card', 'city', $this->string(255));
// $this->addColumn('user_card', 'city', $this->integer(11)->notNull()->defaultValue('1'));
// $this->addForeignKey(
// 'city',
// 'user_card',
// 'city',
// 'cities',
// 'id',
// 'RESTRICT',
// 'CASCADE'
// );
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('cityID', 'user_card');
$this->dropColumn('user_card', 'city');
}
}