diff --git a/backend/views/persone/_form_language.php b/backend/views/persone/_form_language.php index 991234b..04fbdc0 100755 --- a/backend/views/persone/_form_language.php +++ b/backend/views/persone/_form_language.php @@ -28,6 +28,9 @@ ) ->textInput([ 'maxlength' => true ]); ?> +field($model_lang, '[' . $language->id . ']preview') + ->textarea() ?> + field($model_lang, '[' . $language->id . ']text') ->widget( diff --git a/common/models/PersoneLang.php b/common/models/PersoneLang.php index 586445a..5eb8183 100755 --- a/common/models/PersoneLang.php +++ b/common/models/PersoneLang.php @@ -1,105 +1,155 @@ [ - 'class' => SlugBehavior::className(), - 'action' => 'persone/view', - 'params' => [ - 'id' => 'persone_id', + /** + * @inheritdoc + */ + public static function tableName() + { + return 'persone_lang'; + } + + /** + * @inheritdoc + */ + public static function primaryKey() + { + return [ + 'persone_id', + 'language_id', + ]; + } + + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + 'slug' => [ + 'class' => SlugBehavior::className(), + 'action' => 'persone/view', + 'params' => [ + 'id' => 'persone_id', + ], + 'fields' => [], ], - 'fields' => [ + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'persone_id', + 'language_id', + 'alias_id', + ], + 'integer', ], - ], - ]; - } + [ + [ + 'text', + 'preview', + ], + 'string', + ], + [ + [ 'title' ], + 'string', + 'max' => 255, + ], + [ + [ + 'persone_id', + 'language_id', + ], + 'unique', + 'targetAttribute' => [ + 'persone_id', + 'language_id', + ], + 'message' => 'The combination of Persone ID and Language ID has already been taken.', + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'id' ], + ], + [ + [ 'persone_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Persone::className(), + 'targetAttribute' => [ 'persone_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'persone_id' => Yii::t('app', 'Persone ID'), + 'language_id' => Yii::t('app', 'Language ID'), + 'alias_id' => Yii::t('app', 'Alias ID'), + 'title' => Yii::t('app', 'Title'), + 'text' => Yii::t('app', 'Text'), + 'preview' => Yii::t('app', 'Preview'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getPersone() + { + return $this->hasOne(Persone::className(), [ 'id' => 'persone_id' ]); + } - /** - * @inheritdoc - */ - public function rules() - { - return [ - [['persone_id', 'language_id', 'alias_id'], 'integer'], - [['text'], 'string'], - [['title'], 'string', 'max' => 255], - [['persone_id', 'language_id'], 'unique', 'targetAttribute' => ['persone_id', 'language_id'], 'message' => 'The combination of Persone ID and Language ID has already been taken.'], - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'id']], - [['persone_id'], 'exist', 'skipOnError' => true, 'targetClass' => Persone::className(), 'targetAttribute' => ['persone_id' => 'id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'persone_id' => Yii::t('app', 'Persone ID'), - 'language_id' => Yii::t('app', 'Language ID'), - 'alias_id' => Yii::t('app', 'Alias ID'), - 'title' => Yii::t('app', 'Title'), - 'text' => Yii::t('app', 'Text'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getLanguage() - { - return $this->hasOne(Language::className(), ['id' => 'language_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getPersone() - { - return $this->hasOne(Persone::className(), ['id' => 'persone_id']); + /** + * @return \yii\db\ActiveQuery + */ + public function getAlias() + { + return $this->hasOne(Alias::className(), [ 'id' => 'alias_id' ]); + } } -} diff --git a/console/migrations/m170929_083119_add_preview_column_to_persone_lang.php b/console/migrations/m170929_083119_add_preview_column_to_persone_lang.php new file mode 100644 index 0000000..a64b3eb --- /dev/null +++ b/console/migrations/m170929_083119_add_preview_column_to_persone_lang.php @@ -0,0 +1,16 @@ +addColumn('persone_lang', 'preview', $this->string()); + } + + public function safeDown() + { + $this->dropColumn('persone_lang', 'preview'); + } + } diff --git a/frontend/config/main.php b/frontend/config/main.php index fcb3e70..dda3aaf 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -57,6 +57,7 @@ 'blog/category', 'blog/tag', 'blog/article', + 'persone/view', ], 'rules' => [ '\/robots.txt' => 'site/robots', diff --git a/frontend/controllers/PersoneController.php b/frontend/controllers/PersoneController.php new file mode 100644 index 0000000..2a79b4b --- /dev/null +++ b/frontend/controllers/PersoneController.php @@ -0,0 +1,69 @@ +with('lang.alias') + ->all(); + + return $this->render( + 'index', + [ + 'persones' => $persones, + ] + ); + } + + /** + * @param int $id + * + * @return string + */ + public function actionView(int $id) + { + $model = $this->findModel($id); + + return $this->render( + 'view', + [ + 'model' => $model, + ] + ); + } + + /** + * @param $id + * + * @return array|null|\yii\db\ActiveRecord + * @throws \yii\web\NotFoundHttpException + */ + protected function findModel($id) + { + $model = Persone::find() + ->with('lang.alias') + ->where([ 'id' => $id ]) + ->one(); + + if (empty($model)) { + throw new NotFoundHttpException(); + } else { + return $model; + } + } + } \ No newline at end of file diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index c13938f..51f4ccc 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -323,6 +323,10 @@ _________________________________________________________ --> 'label' => \Yii::t('app', 'Галерея'), 'url' => [ 'site/gallery' ], ]; + $items[] = [ + 'label' => \Yii::t('app', 'Персонал'), + 'url' => [ 'persone/index' ], + ]; echo Nav::widget( [ 'items' => $items, diff --git a/frontend/views/persone/_persone.php b/frontend/views/persone/_persone.php new file mode 100644 index 0000000..cf28896 --- /dev/null +++ b/frontend/views/persone/_persone.php @@ -0,0 +1,56 @@ + + +
+
+ +

lang->title ?>

+ + +
+

lang->preview ?>

+
+
+ +
diff --git a/frontend/views/persone/index.php b/frontend/views/persone/index.php new file mode 100644 index 0000000..5a4ef59 --- /dev/null +++ b/frontend/views/persone/index.php @@ -0,0 +1,50 @@ +params[ 'breadcrumbs' ][] = \Yii::t('app', 'Персонал'); + +?> + +
+
+ +
+ +
+
+
+

Who is responsible for Universal?

+
+ +

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean + ultricies mi vitae est. Mauris placerat eleifend leo.

+
+
+ +
+ render( + '_persone', + [ + 'model' => $persone, + ] + ); + } ?> +
+ + +
+ +
+ +
+ + \ No newline at end of file diff --git a/frontend/views/persone/view.php b/frontend/views/persone/view.php new file mode 100644 index 0000000..c749f12 --- /dev/null +++ b/frontend/views/persone/view.php @@ -0,0 +1,74 @@ +params[ 'breadcrumbs' ][] = [ + 'url' => [ 'persone/index' ], + 'label' => \Yii::t('app', 'песонал'), + ]; + + $this->params[ 'breadcrumbs' ][] = $model->lang->title; + +?> + +
+
+
+
+
+
+

lang->title ?>

+
+

Do greatest at in learning steepest. Breakfast extremity suffering one who all otherwise suspected. He at no nothing forbade up moments. Wholly uneasy at missed be of pretty whence. John way sir high than law who week. Surrounded + prosperous introduced it if is up dispatched. Improved so strictly produced answered elegance is.

+
+
+ +
+
+ + lang->text ?> + +
+

Get in touch with Han

+
+ + +
+ +
+ image->getPath()) + ->cropResize(360, 360) + ->renderImage( + [ + 'class' => 'img-responsive img-circle', + 'alt' => $model->lang->title, + ] + ) ?> +
+
+
+ +
+ + + +
+ + \ No newline at end of file -- libgit2 0.21.4