Commit 84ebac3d89b3b71ea30593fa555948233331d949
1 parent
a952c014
test
Showing
9 changed files
with
578 additions
and
26 deletions
Show diff stats
1 | +<?php | ||
2 | + | ||
3 | + namespace common\models; | ||
4 | + | ||
5 | + use Yii; | ||
6 | + use yii\behaviors\BlameableBehavior; | ||
7 | + use yii\behaviors\TimestampBehavior; | ||
8 | + use yii\db\Expression; | ||
9 | + | ||
10 | + /** | ||
11 | + * This is the model class for table "blog". | ||
12 | + * @property integer $blog_id | ||
13 | + * @property integer $user_id | ||
14 | + * @property string $name | ||
15 | + * @property string $link | ||
16 | + * @property string $date_add | ||
17 | + * @property integer $user_add_id | ||
18 | + * @property integer $view_count | ||
19 | + * @property string $description | ||
20 | + * @property string $cover | ||
21 | + */ | ||
22 | + class Blog extends \yii\db\ActiveRecord | ||
23 | + { | ||
24 | + | ||
25 | + /** | ||
26 | + * @inheritdoc | ||
27 | + */ | ||
28 | + public static function tableName() | ||
29 | + { | ||
30 | + return 'blog'; | ||
31 | + } | ||
32 | + | ||
33 | + /** | ||
34 | + * @inheritdoc | ||
35 | + */ | ||
36 | + public function behaviors() | ||
37 | + { | ||
38 | + return [ | ||
39 | + [ | ||
40 | + 'class' => BlameableBehavior::className(), | ||
41 | + 'createdByAttribute' => 'user_id', | ||
42 | + 'updatedByAttribute' => false, | ||
43 | + ], | ||
44 | + [ | ||
45 | + 'class' => TimestampBehavior::className(), | ||
46 | + 'createdAtAttribute' => 'date_add', | ||
47 | + 'updatedAtAttribute' => false, | ||
48 | + 'value' => new Expression('NOW()'), | ||
49 | + ], | ||
50 | + ]; | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * @inheritdoc | ||
55 | + */ | ||
56 | + public function rules() | ||
57 | + { | ||
58 | + return [ | ||
59 | + [ | ||
60 | + [ 'name' ], | ||
61 | + 'required', | ||
62 | + ], | ||
63 | + [ | ||
64 | + [ 'description' ], | ||
65 | + 'string', | ||
66 | + ], | ||
67 | + [ | ||
68 | + [ | ||
69 | + 'name', | ||
70 | + 'link', | ||
71 | + 'cover', | ||
72 | + ], | ||
73 | + 'string', | ||
74 | + 'max' => 255, | ||
75 | + ], | ||
76 | + ]; | ||
77 | + } | ||
78 | + | ||
79 | + /** | ||
80 | + * @inheritdoc | ||
81 | + */ | ||
82 | + public function attributeLabels() | ||
83 | + { | ||
84 | + return [ | ||
85 | + 'blog_id' => Yii::t('app', 'Blog ID'), | ||
86 | + 'user_id' => Yii::t('app', 'User ID'), | ||
87 | + 'name' => Yii::t('app', 'Название'), | ||
88 | + 'link' => Yii::t('app', 'URL'), | ||
89 | + 'date_add' => Yii::t('app', 'Дата добавления'), | ||
90 | + 'user_add_id' => Yii::t('app', 'User Add ID'), | ||
91 | + 'view_count' => Yii::t('app', 'Количество просмотров'), | ||
92 | + 'description' => Yii::t('app', 'Описание'), | ||
93 | + 'cover' => Yii::t('app', 'Фото главное'), | ||
94 | + ]; | ||
95 | + } | ||
96 | + } |
common/models/Portfolio.php
@@ -9,24 +9,25 @@ | @@ -9,24 +9,25 @@ | ||
9 | 9 | ||
10 | /** | 10 | /** |
11 | * This is the model class for table "portfolio". | 11 | * This is the model class for table "portfolio". |
12 | - * @property integer $portfolio_id | ||
13 | - * @property integer $user_id | ||
14 | - * @property string $name | ||
15 | - * @property string $link | ||
16 | - * @property string $date_add | ||
17 | - * @property integer $user_add_id Currently inactive attribute | ||
18 | - * @property integer $view_count | ||
19 | - * @property string $city | ||
20 | - * @property string $street | ||
21 | - * @property string $house | ||
22 | - * @property string $description | ||
23 | - * @property string $cover | ||
24 | - * @property integer $gallery_id | 12 | + * @property integer $portfolio_id |
13 | + * @property integer $user_id | ||
14 | + * @property string $name | ||
15 | + * @property string $link | ||
16 | + * @property string $date_add | ||
17 | + * @property integer $user_add_id Currently inactive attribute | ||
18 | + * @property integer $view_count | ||
19 | + * @property string $city | ||
20 | + * @property string $street | ||
21 | + * @property string $house | ||
22 | + * @property string $description | ||
23 | + * @property string $cover | ||
24 | + * @property integer $gallery_id | ||
25 | * @property PortfolioSpecialization[] $portfolioSpecializations | 25 | * @property PortfolioSpecialization[] $portfolioSpecializations |
26 | - * @property Specialization[] $specializations | 26 | + * @property Specialization[] $specializations |
27 | */ | 27 | */ |
28 | class Portfolio extends \yii\db\ActiveRecord | 28 | class Portfolio extends \yii\db\ActiveRecord |
29 | { | 29 | { |
30 | + | ||
30 | /** | 31 | /** |
31 | * @inheritdoc | 32 | * @inheritdoc |
32 | */ | 33 | */ |
@@ -42,15 +43,15 @@ | @@ -42,15 +43,15 @@ | ||
42 | { | 43 | { |
43 | return [ | 44 | return [ |
44 | [ | 45 | [ |
45 | - 'class' => BlameableBehavior::className(), | 46 | + 'class' => BlameableBehavior::className(), |
46 | 'createdByAttribute' => 'user_id', | 47 | 'createdByAttribute' => 'user_id', |
47 | 'updatedByAttribute' => false, | 48 | 'updatedByAttribute' => false, |
48 | ], | 49 | ], |
49 | [ | 50 | [ |
50 | - 'class' => TimestampBehavior::className(), | 51 | + 'class' => TimestampBehavior::className(), |
51 | 'createdAtAttribute' => 'date_add', | 52 | 'createdAtAttribute' => 'date_add', |
52 | 'updatedAtAttribute' => false, | 53 | 'updatedAtAttribute' => false, |
53 | - 'value' => new Expression('NOW()'), | 54 | + 'value' => new Expression('NOW()'), |
54 | ], | 55 | ], |
55 | ]; | 56 | ]; |
56 | } | 57 | } |
@@ -69,7 +70,6 @@ | @@ -69,7 +70,6 @@ | ||
69 | ], | 70 | ], |
70 | [ | 71 | [ |
71 | [ | 72 | [ |
72 | - 'view_count', | ||
73 | 'gallery_id', | 73 | 'gallery_id', |
74 | ], | 74 | ], |
75 | 'integer', | 75 | 'integer', |
@@ -94,7 +94,7 @@ | @@ -94,7 +94,7 @@ | ||
94 | ], | 94 | ], |
95 | [ | 95 | [ |
96 | [ | 96 | [ |
97 | - 'specializationInput' | 97 | + 'specializationInput', |
98 | ], | 98 | ], |
99 | 'safe', | 99 | 'safe', |
100 | ], | 100 | ], |
@@ -139,7 +139,9 @@ | @@ -139,7 +139,9 @@ | ||
139 | 139 | ||
140 | public function getSpecializationInput() | 140 | public function getSpecializationInput() |
141 | { | 141 | { |
142 | - return $this->getSpecializations()->asArray()->column(); | 142 | + return $this->getSpecializations() |
143 | + ->asArray() | ||
144 | + ->column(); | ||
143 | } | 145 | } |
144 | 146 | ||
145 | public function setSpecializationInput($value) | 147 | public function setSpecializationInput($value) |
1 | +<?php | ||
2 | + | ||
3 | + namespace common\models; | ||
4 | + | ||
5 | + use Yii; | ||
6 | + use yii\behaviors\BlameableBehavior; | ||
7 | + use yii\behaviors\TimestampBehavior; | ||
8 | + use yii\db\Expression; | ||
9 | + | ||
10 | + /** | ||
11 | + * This is the model class for table "project". | ||
12 | + * @property integer $project_id | ||
13 | + * @property integer $user_id | ||
14 | + * @property string $name | ||
15 | + * @property string $link | ||
16 | + * @property integer $project_pid | ||
17 | + * @property string $date_add | ||
18 | + * @property string $date_end | ||
19 | + * @property integer $user_add_id | ||
20 | + * @property double $view_count | ||
21 | + * @property string $budget | ||
22 | + * @property string $city | ||
23 | + * @property string $street | ||
24 | + * @property string $house | ||
25 | + * @property integer $payment_variant | ||
26 | + * @property integer $deadline | ||
27 | + * @property string $description | ||
28 | + * @property integer $contractual | ||
29 | + * @property ProjectPayment[] $projectPayments | ||
30 | + * @property ProjectSpecialization[] $projectSpecializations | ||
31 | + * @property Specialization[] $specializations | ||
32 | + */ | ||
33 | + class Project extends \yii\db\ActiveRecord | ||
34 | + { | ||
35 | + | ||
36 | + /** | ||
37 | + * @inheritdoc | ||
38 | + */ | ||
39 | + public static function tableName() | ||
40 | + { | ||
41 | + return 'project'; | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * @inheritdoc | ||
46 | + */ | ||
47 | + public function behaviors() | ||
48 | + { | ||
49 | + return [ | ||
50 | + [ | ||
51 | + 'class' => BlameableBehavior::className(), | ||
52 | + 'createdByAttribute' => 'user_id', | ||
53 | + 'updatedByAttribute' => false, | ||
54 | + ], | ||
55 | + [ | ||
56 | + 'class' => TimestampBehavior::className(), | ||
57 | + 'createdAtAttribute' => 'date_add', | ||
58 | + 'updatedAtAttribute' => false, | ||
59 | + 'value' => new Expression('NOW()'), | ||
60 | + ], | ||
61 | + ]; | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * @inheritdoc | ||
66 | + */ | ||
67 | + public function rules() | ||
68 | + { | ||
69 | + return [ | ||
70 | + [ | ||
71 | + [ 'name' ], | ||
72 | + 'required', | ||
73 | + ], | ||
74 | + [ | ||
75 | + [ | ||
76 | + 'project_pid', | ||
77 | + 'payment_variant', | ||
78 | + 'contractual', | ||
79 | + ], | ||
80 | + 'integer', | ||
81 | + ], | ||
82 | + [ | ||
83 | + [ 'description' ], | ||
84 | + 'string', | ||
85 | + ], | ||
86 | + [ | ||
87 | + [ | ||
88 | + 'name', | ||
89 | + 'link', | ||
90 | + 'budget', | ||
91 | + 'city', | ||
92 | + 'street', | ||
93 | + 'house', | ||
94 | + ], | ||
95 | + 'string', | ||
96 | + 'max' => 255, | ||
97 | + ], | ||
98 | + ]; | ||
99 | + } | ||
100 | + | ||
101 | + /** | ||
102 | + * @inheritdoc | ||
103 | + */ | ||
104 | + public function attributeLabels() | ||
105 | + { | ||
106 | + return [ | ||
107 | + 'project_id' => Yii::t('app', 'Project ID'), | ||
108 | + 'user_id' => Yii::t('app', 'User ID'), | ||
109 | + 'name' => Yii::t('app', 'Название'), | ||
110 | + 'link' => Yii::t('app', 'URL'), | ||
111 | + 'project_pid' => Yii::t('app', 'Родительский проект'), | ||
112 | + 'date_add' => Yii::t('app', 'Дата добавления'), | ||
113 | + 'date_end' => Yii::t('app', 'Дата окончания'), | ||
114 | + 'user_add_id' => Yii::t('app', 'User Add ID'), | ||
115 | + 'view_count' => Yii::t('app', 'Количество просмотров'), | ||
116 | + 'budget' => Yii::t('app', 'Бюджет'), | ||
117 | + 'city' => Yii::t('app', 'Город'), | ||
118 | + 'street' => Yii::t('app', 'Улица'), | ||
119 | + 'house' => Yii::t('app', 'Дом'), | ||
120 | + 'payment_variant' => Yii::t('app', 'Варианты оплаты'), | ||
121 | + 'deadline' => Yii::t('app', 'Deadline'), | ||
122 | + 'description' => Yii::t('app', 'Описание'), | ||
123 | + 'contractual' => Yii::t('app', 'Договорной'), | ||
124 | + ]; | ||
125 | + } | ||
126 | + | ||
127 | + /** | ||
128 | + * @return \yii\db\ActiveQuery | ||
129 | + */ | ||
130 | + public function getProjectPayments() | ||
131 | + { | ||
132 | + return $this->hasMany(ProjectPayment::className(), [ 'project_id' => 'project_id' ]); | ||
133 | + } | ||
134 | + | ||
135 | + public function getPayments() | ||
136 | + { | ||
137 | + return $this->hasMany(Payment::className(), [ 'payment_id' => 'payment_id' ]) | ||
138 | + ->viaTable('project_specialization', [ 'project_id' => 'project_id' ]); | ||
139 | + } | ||
140 | + | ||
141 | + /** | ||
142 | + * @return \yii\db\ActiveQuery | ||
143 | + */ | ||
144 | + public function getProjectSpecializations() | ||
145 | + { | ||
146 | + return $this->hasMany(ProjectSpecialization::className(), [ 'project_id' => 'project_id' ]); | ||
147 | + } | ||
148 | + | ||
149 | + public function getSpecializations() | ||
150 | + { | ||
151 | + return $this->hasMany(Specialization::className(), [ 'specialization_id' => 'specialization_id' ]) | ||
152 | + ->viaTable('project_specialization', [ 'project_id' => 'project_id' ]); | ||
153 | + } | ||
154 | + | ||
155 | + public function getSpecializationInput() | ||
156 | + { | ||
157 | + return $this->getSpecializations() | ||
158 | + ->asArray() | ||
159 | + ->column(); | ||
160 | + } | ||
161 | + | ||
162 | + public function setSpecializationInput($value) { | ||
163 | + $this->specializationInput = $value; | ||
164 | + } | ||
165 | + | ||
166 | + public function getPaymentInput() | ||
167 | + { | ||
168 | + return $this->getPayments() | ||
169 | + ->asArray() | ||
170 | + ->column(); | ||
171 | + } | ||
172 | + | ||
173 | + public function setPaymentInput($value) { | ||
174 | + $this->paymentInput = $value; | ||
175 | + } | ||
176 | + } |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "project_payment". | ||
9 | + * | ||
10 | + * @property integer $project_payment_id | ||
11 | + * @property integer $project_id | ||
12 | + * @property integer $payment_id | ||
13 | + * | ||
14 | + * @property Payment $payment | ||
15 | + * @property Project $project | ||
16 | + */ | ||
17 | +class ProjectPayment extends \yii\db\ActiveRecord | ||
18 | +{ | ||
19 | + /** | ||
20 | + * @inheritdoc | ||
21 | + */ | ||
22 | + public static function tableName() | ||
23 | + { | ||
24 | + return 'project_payment'; | ||
25 | + } | ||
26 | + | ||
27 | + /** | ||
28 | + * @inheritdoc | ||
29 | + */ | ||
30 | + public function rules() | ||
31 | + { | ||
32 | + return [ | ||
33 | + [['project_id', 'payment_id'], 'integer'], | ||
34 | + [['payment_id'], 'exist', 'skipOnError' => true, 'targetClass' => Payment::className(), 'targetAttribute' => ['payment_id' => 'payment_id']], | ||
35 | + [['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'project_id']], | ||
36 | + ]; | ||
37 | + } | ||
38 | + | ||
39 | + /** | ||
40 | + * @inheritdoc | ||
41 | + */ | ||
42 | + public function attributeLabels() | ||
43 | + { | ||
44 | + return [ | ||
45 | + 'project_payment_id' => Yii::t('app', 'Project Payment ID'), | ||
46 | + 'project_id' => Yii::t('app', 'Project ID'), | ||
47 | + 'payment_id' => Yii::t('app', 'Payment ID'), | ||
48 | + ]; | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * @return \yii\db\ActiveQuery | ||
53 | + */ | ||
54 | + public function getPayment() | ||
55 | + { | ||
56 | + return $this->hasOne(Payment::className(), ['payment_id' => 'payment_id']); | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * @return \yii\db\ActiveQuery | ||
61 | + */ | ||
62 | + public function getProject() | ||
63 | + { | ||
64 | + return $this->hasOne(Project::className(), ['project_id' => 'project_id']); | ||
65 | + } | ||
66 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "project_specialization". | ||
9 | + * | ||
10 | + * @property integer $project_specialization_id | ||
11 | + * @property integer $project_id | ||
12 | + * @property integer $specialization_id | ||
13 | + * | ||
14 | + * @property Project $project | ||
15 | + * @property Specialization $specialization | ||
16 | + */ | ||
17 | +class ProjectSpecialization extends \yii\db\ActiveRecord | ||
18 | +{ | ||
19 | + /** | ||
20 | + * @inheritdoc | ||
21 | + */ | ||
22 | + public static function tableName() | ||
23 | + { | ||
24 | + return 'project_specialization'; | ||
25 | + } | ||
26 | + | ||
27 | + /** | ||
28 | + * @inheritdoc | ||
29 | + */ | ||
30 | + public function rules() | ||
31 | + { | ||
32 | + return [ | ||
33 | + [['project_id', 'specialization_id'], 'integer'], | ||
34 | + [['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'project_id']], | ||
35 | + [['specialization_id'], 'exist', 'skipOnError' => true, 'targetClass' => Specialization::className(), 'targetAttribute' => ['specialization_id' => 'specialization_id']], | ||
36 | + ]; | ||
37 | + } | ||
38 | + | ||
39 | + /** | ||
40 | + * @inheritdoc | ||
41 | + */ | ||
42 | + public function attributeLabels() | ||
43 | + { | ||
44 | + return [ | ||
45 | + 'project_specialization_id' => Yii::t('app', 'Project Specialization ID'), | ||
46 | + 'project_id' => Yii::t('app', 'Project ID'), | ||
47 | + 'specialization_id' => Yii::t('app', 'Specialization ID'), | ||
48 | + ]; | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * @return \yii\db\ActiveQuery | ||
53 | + */ | ||
54 | + public function getProject() | ||
55 | + { | ||
56 | + return $this->hasOne(Project::className(), ['project_id' => 'project_id']); | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * @return \yii\db\ActiveQuery | ||
61 | + */ | ||
62 | + public function getSpecialization() | ||
63 | + { | ||
64 | + return $this->hasOne(Specialization::className(), ['specialization_id' => 'specialization_id']); | ||
65 | + } | ||
66 | +} |
console/migrations/m160209_104201_add_field_project_budget.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +use yii\db\Migration; | ||
4 | + | ||
5 | +class m160209_104201_add_field_project_budget extends Migration | ||
6 | +{ | ||
7 | + public function up() | ||
8 | + { | ||
9 | + $this->addColumn('{{%project}}', 'contractual', $this->smallInteger()); | ||
10 | + } | ||
11 | + | ||
12 | + public function down() | ||
13 | + { | ||
14 | + $this->dropColumn('{{%project}}', 'contractual'); | ||
15 | + } | ||
16 | +} |
frontend/controllers/AccountsController.php
1 | <?php | 1 | <?php |
2 | namespace frontend\controllers; | 2 | namespace frontend\controllers; |
3 | 3 | ||
4 | + use common\models\Blog; | ||
4 | use common\models\CompanyInfo; | 5 | use common\models\CompanyInfo; |
5 | use common\models\Fields; | 6 | use common\models\Fields; |
6 | use common\models\Job; | 7 | use common\models\Job; |
@@ -8,6 +9,7 @@ | @@ -8,6 +9,7 @@ | ||
8 | use common\models\Payment; | 9 | use common\models\Payment; |
9 | use common\models\Portfolio; | 10 | use common\models\Portfolio; |
10 | use common\models\PortfolioSpecialization; | 11 | use common\models\PortfolioSpecialization; |
12 | + use common\models\Project; | ||
11 | use common\models\Specialization; | 13 | use common\models\Specialization; |
12 | use common\models\UserPayment; | 14 | use common\models\UserPayment; |
13 | use common\models\UserSpecialization; | 15 | use common\models\UserSpecialization; |
@@ -110,6 +112,33 @@ | @@ -110,6 +112,33 @@ | ||
110 | ]); | 112 | ]); |
111 | } | 113 | } |
112 | 114 | ||
115 | + public function actionBlog() | ||
116 | + { | ||
117 | + return $this->render('blog'); | ||
118 | + } | ||
119 | + | ||
120 | + public function actionBlogCreate() | ||
121 | + { | ||
122 | + $blog = new Blog(); | ||
123 | + $post = \Yii::$app->request->post(); | ||
124 | + if($blog->load($post) && $blog->save()) { | ||
125 | + return $this->redirect('blog'); | ||
126 | + } else { | ||
127 | + return $this->render('_blog_form', [ 'blog' => $blog ]); | ||
128 | + } | ||
129 | + } | ||
130 | + | ||
131 | + public function actionBlogUpdate($id) | ||
132 | + { | ||
133 | + $blog = Blog::findOne($id); | ||
134 | + $post = \Yii::$app->request->post(); | ||
135 | + if($blog->load($post) && $blog->save()) { | ||
136 | + return $this->redirect('blog'); | ||
137 | + } else { | ||
138 | + return $this->render('_blog_form', [ 'blog' => $blog ]); | ||
139 | + } | ||
140 | + } | ||
141 | + | ||
113 | public function actionPortfolio() | 142 | public function actionPortfolio() |
114 | { | 143 | { |
115 | return $this->render('portfolio'); | 144 | return $this->render('portfolio'); |
@@ -127,7 +156,7 @@ | @@ -127,7 +156,7 @@ | ||
127 | ->asArray() | 156 | ->asArray() |
128 | ->column(); | 157 | ->column(); |
129 | $post = \Yii::$app->request->post(); | 158 | $post = \Yii::$app->request->post(); |
130 | - if(!empty($post)) { | 159 | + if(!empty( $post )) { |
131 | $portfolio->load($post); | 160 | $portfolio->load($post); |
132 | $portfolio->validate(); | 161 | $portfolio->validate(); |
133 | if(!$portfolio->hasErrors()) { | 162 | if(!$portfolio->hasErrors()) { |
@@ -136,10 +165,13 @@ | @@ -136,10 +165,13 @@ | ||
136 | foreach($portfolio->specializationInput as $one_specialization) { | 165 | foreach($portfolio->specializationInput as $one_specialization) { |
137 | $portfolio->link('specializations', Specialization::findOne($one_specialization)); | 166 | $portfolio->link('specializations', Specialization::findOne($one_specialization)); |
138 | } | 167 | } |
139 | - return $this->render('portfolio'); | 168 | + return $this->redirect('portfolio'); |
140 | } | 169 | } |
141 | } | 170 | } |
142 | - return $this->render('_portfolio_form', [ 'portfolio' => $portfolio, 'specialization' => $specialization ]); | 171 | + return $this->render('_portfolio_form', [ |
172 | + 'portfolio' => $portfolio, | ||
173 | + 'specialization' => $specialization, | ||
174 | + ]); | ||
143 | } | 175 | } |
144 | 176 | ||
145 | public function actionPortfolioUpdate($id) | 177 | public function actionPortfolioUpdate($id) |
@@ -154,7 +186,7 @@ | @@ -154,7 +186,7 @@ | ||
154 | ->asArray() | 186 | ->asArray() |
155 | ->column(); | 187 | ->column(); |
156 | $post = \Yii::$app->request->post(); | 188 | $post = \Yii::$app->request->post(); |
157 | - if(!empty($post)) { | 189 | + if(!empty( $post )) { |
158 | $portfolio->load($post); | 190 | $portfolio->load($post); |
159 | $portfolio->validate(); | 191 | $portfolio->validate(); |
160 | if(!$portfolio->hasErrors()) { | 192 | if(!$portfolio->hasErrors()) { |
@@ -163,10 +195,13 @@ | @@ -163,10 +195,13 @@ | ||
163 | foreach($portfolio->specializationInput as $one_specialization) { | 195 | foreach($portfolio->specializationInput as $one_specialization) { |
164 | $portfolio->link('specializations', Specialization::findOne($one_specialization)); | 196 | $portfolio->link('specializations', Specialization::findOne($one_specialization)); |
165 | } | 197 | } |
166 | - return $this->render('portfolio'); | 198 | + return $this->redirect('portfolio'); |
167 | } | 199 | } |
168 | } | 200 | } |
169 | - return $this->render('_portfolio_form', [ 'portfolio' => $portfolio, 'specialization' => $specialization ]); | 201 | + return $this->render('_portfolio_form', [ |
202 | + 'portfolio' => $portfolio, | ||
203 | + 'specialization' => $specialization, | ||
204 | + ]); | ||
170 | } | 205 | } |
171 | 206 | ||
172 | /** | 207 | /** |
@@ -360,6 +395,45 @@ | @@ -360,6 +395,45 @@ | ||
360 | return $this->render('projects'); | 395 | return $this->render('projects'); |
361 | } | 396 | } |
362 | 397 | ||
398 | + public function actionProjectsCreate() | ||
399 | + { | ||
400 | + $project = new Project(); | ||
401 | + $specialization = Specialization::find() | ||
402 | + ->select([ | ||
403 | + 'specialization_name', | ||
404 | + 'specialization_id', | ||
405 | + ]) | ||
406 | + ->indexBy('specialization_id') | ||
407 | + ->asArray() | ||
408 | + ->column(); | ||
409 | + $payment = Payment::find() | ||
410 | + ->select([ | ||
411 | + 'name', | ||
412 | + 'payment_id', | ||
413 | + ]) | ||
414 | + ->indexBy('payment_id') | ||
415 | + ->asArray() | ||
416 | + ->column(); | ||
417 | + $post = \Yii::$app->request->post(); | ||
418 | + if(!empty($post)) { | ||
419 | + $project->load($post); | ||
420 | + $project->validate(); | ||
421 | + if(!$project->hasErrors()) { | ||
422 | + $project->save(); | ||
423 | + $project->unlinkAll('specializations', true); | ||
424 | + foreach($project->specializationInput as $one_specialization) { | ||
425 | + $project->link('specialization', Specialization::findOne($one_specialization)); | ||
426 | + } | ||
427 | + $project->unlinkAll('payments', true); | ||
428 | + foreach($project->paymentInput as $one_payment) { | ||
429 | + $project->link('payment', Payment::findOne($one_payment)); | ||
430 | + } | ||
431 | + return $this->redirect('projects'); | ||
432 | + } | ||
433 | + } | ||
434 | + return $this->render('_projects_form', [ 'project' => $project, 'specialization' => $specialization, 'payment' => $payment ]); | ||
435 | + } | ||
436 | + | ||
363 | public function actionGallery() | 437 | public function actionGallery() |
364 | { | 438 | { |
365 | 439 |
1 | +<?php | ||
2 | + /** | ||
3 | + * @var Blog $blog | ||
4 | + */ | ||
5 | + use common\models\Blog; | ||
6 | + use common\widgets\ImageUploader; | ||
7 | + use mihaildev\ckeditor\CKEditor; | ||
8 | + use yii\helpers\Html; | ||
9 | + use yii\widgets\ActiveForm; | ||
10 | + | ||
11 | + $this->title = 'Мой профиль'; | ||
12 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
13 | +?> | ||
14 | +<h1><?= $this->title ?></h1> | ||
15 | + | ||
16 | +<?php | ||
17 | + $form = ActiveForm::begin(); | ||
18 | +?> | ||
19 | + | ||
20 | +<?= $form->field($blog, 'date_add') | ||
21 | + ->textInput([ 'disabled' => 'disabled' ]) ?> | ||
22 | + | ||
23 | +<?= $form->field($blog, 'name') | ||
24 | + ->textInput() ?> | ||
25 | + | ||
26 | +<?= $form->field($blog, 'link') | ||
27 | + ->textInput() ?> | ||
28 | + | ||
29 | +<?= $form->field($blog, 'description')->widget(CKEditor::className()) ?> | ||
30 | + | ||
31 | +<?= ImageUploader::widget([ | ||
32 | + 'model'=> $blog, | ||
33 | + 'field'=>'cover', | ||
34 | + 'width'=>100, | ||
35 | + 'height'=>100, | ||
36 | + 'multi'=>false, | ||
37 | + 'gallery' =>$blog->cover, | ||
38 | + 'name' => 'Загрузить главное фото' | ||
39 | +]); | ||
40 | +?> | ||
41 | + | ||
42 | +<?= Html::submitButton('Добавить') ?> | ||
43 | + | ||
44 | +<?php | ||
45 | + $form->end(); | ||
46 | +?> |
1 | +<?php | ||
2 | +use common\models\Option; | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\ActiveForm; | ||
5 | +use \common\widgets\MultiLangForm; | ||
6 | + | ||
7 | + $this->title = 'Мой профиль'; | ||
8 | + $this->params['breadcrumbs'][] = $this->title; | ||
9 | +?> | ||
10 | +<h1><?= $this->title ?></h1> | ||
0 | \ No newline at end of file | 11 | \ No newline at end of file |