Skip to content

Commit 7b293e4

Browse files
committed
added photograph,author and publication place
1 parent 772918d commit 7b293e4

File tree

5 files changed

+56
-2
lines changed

5 files changed

+56
-2
lines changed

controllers/backend/BlogPostController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function actionUpdate($id)
133133
$model->save(false);
134134
return $this->redirect(['view', 'id' => $model->id]);
135135
} else {
136-
return $this->render('create', [
136+
return $this->render('update', [
137137
'model' => $model,
138138
]);
139139
}

messages/ru-RU/blog.php

+3
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,8 @@
111111
'Results' => 'Результаты',
112112
'Gratitude' => 'Благодарности',
113113
'Fundraising is closed' => 'Сбор средств закрыт',
114+
115+
'Photograph'=>'Фотограф',
116+
'Publication Place'=>'Место публикации',
114117
];
115118

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
use yii\db\Migration;
4+
5+
/**
6+
* Class m171016_123739_add_columns_to_blog_post
7+
*/
8+
class m171016_123739_add_columns_to_blog_post extends Migration
9+
{
10+
/**
11+
* @inheritdoc
12+
*/
13+
public function safeUp()
14+
{
15+
$this->addColumn('{{%blog_post}}', 'author', $this->string()->null());
16+
$this->addColumn('{{%blog_post}}', 'photograph', $this->string()->null());
17+
$this->addColumn('{{%blog_post}}', 'place', $this->string()->null());
18+
}
19+
20+
/**
21+
* @inheritdoc
22+
*/
23+
public function safeDown()
24+
{
25+
echo "m171016_123739_add_columns_to_blog_post cannot be reverted.\n";
26+
27+
return false;
28+
}
29+
30+
/*
31+
// Use up()/down() to run migration code without a transaction.
32+
public function up()
33+
{
34+
35+
}
36+
37+
public function down()
38+
{
39+
echo "m171016_123739_add_columns_to_blog_post cannot be reverted.\n";
40+
41+
return false;
42+
}
43+
*/
44+
}

models/BlogPost.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function rules()
8787
// [['catalog_id', 'title', 'content', 'tags', 'surname', 'user_id'], 'required'],
8888
[['catalog_id', 'title', 'content', 'user_id'], 'required'],
8989
[['catalog_id', 'click', 'user_id', 'status', 'likes', 'amount', 'donated'], 'integer'],
90-
[['brief', 'content', 'results', 'gratitude'], 'string'],
90+
[['brief', 'content', 'results', 'gratitude','author','photograph','place'], 'string'],
9191
[['created_at', 'updated_at'], 'safe'],
9292
[['banner'], 'file', 'extensions' => 'jpg, jpeg, png', 'mimeTypes' => 'image/jpeg, image/png',],
9393
[['title', 'tags', 'surname'], 'string', 'max' => 128],
@@ -125,6 +125,9 @@ public function attributeLabels()
125125
'results' => Module::t('blog', 'Results'),
126126
'gratitude' => Module::t('blog', 'Gratitude'),
127127
'closed' => Module::t('blog', 'Fundraising is closed'),
128+
'author' => Module::t('blog', 'Author'),
129+
'photograph' => Module::t('blog', 'Photograph'),
130+
'place' => Module::t('blog', 'Publication Place'),
128131
];
129132
}
130133

views/backend/blog-post/_form.php

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858

5959
<?= $form->field($model, 'tags')->textInput(['maxlength' => 128]) ?>
6060

61+
<?= $form->field($model, 'author')->textInput() ?>
62+
<?= $form->field($model, 'photograph')->textInput() ?>
63+
<?= $form->field($model, 'place')->textInput() ?>
64+
6165
<!-- --><?//= $form->field($model, 'surname')->textInput(['maxlength' => 128]) ?>
6266

6367
<?= $form->field($model, 'banner')->fileInput() ?>

0 commit comments

Comments
 (0)