Commit 4428da8cca9d3e02b2c2515947f37fcbe199b978
1 parent
8af13427
Almost all database finish.
Showing
83 changed files
with
2831 additions
and
1993 deletions
Show diff stats
backend/controllers/OrderController.php
... | ... | @@ -113,7 +113,9 @@ |
113 | 113 | { |
114 | 114 | $model = new orderProduct(); |
115 | 115 | if ($model->load(Yii::$app->request->post())) { |
116 | - | |
116 | + /** | |
117 | + * @var ProductVariant $modelMod | |
118 | + */ | |
117 | 119 | if (!$modelMod = ProductVariant::find() |
118 | 120 | ->with([ 'product' ]) |
119 | 121 | ->where([ 'sku' => $model->sku ]) | ... | ... |
backend/controllers/SeoCategoryController.php
... | ... | @@ -73,7 +73,7 @@ |
73 | 73 | if($model->save() && $model->transactionStatus) { |
74 | 74 | return $this->redirect([ |
75 | 75 | 'view', |
76 | - 'id' => $model->seo_category_id, | |
76 | + 'id' => $model->id, | |
77 | 77 | ]); |
78 | 78 | } |
79 | 79 | } |
... | ... | @@ -100,7 +100,7 @@ |
100 | 100 | if($model->save() && $model->transactionStatus) { |
101 | 101 | return $this->redirect([ |
102 | 102 | 'view', |
103 | - 'id' => $model->seo_category_id, | |
103 | + 'id' => $model->id, | |
104 | 104 | ]); |
105 | 105 | } |
106 | 106 | } |
... | ... | @@ -138,7 +138,7 @@ |
138 | 138 | protected function findModel($id) |
139 | 139 | { |
140 | 140 | if(( $model = SeoCategory::find() |
141 | - ->where([ 'seo_category_id' => $id ]) | |
141 | + ->where([ 'id' => $id ]) | |
142 | 142 | ->with('lang') |
143 | 143 | ->one() ) !== NULL |
144 | 144 | ) { | ... | ... |
backend/controllers/SeoController.php
... | ... | @@ -45,6 +45,7 @@ |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Lists all Seo models. |
48 | + * | |
48 | 49 | * @return mixed |
49 | 50 | */ |
50 | 51 | public function actionIndex() |
... | ... | @@ -52,10 +53,13 @@ |
52 | 53 | $searchModel = new SeoSearch(); |
53 | 54 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); |
54 | 55 | |
55 | - return $this->render('index', [ | |
56 | - 'searchModel' => $searchModel, | |
57 | - 'dataProvider' => $dataProvider, | |
58 | - ]); | |
56 | + return $this->render( | |
57 | + 'index', | |
58 | + [ | |
59 | + 'searchModel' => $searchModel, | |
60 | + 'dataProvider' => $dataProvider, | |
61 | + ] | |
62 | + ); | |
59 | 63 | } |
60 | 64 | |
61 | 65 | /** |
... | ... | @@ -67,14 +71,18 @@ |
67 | 71 | */ |
68 | 72 | public function actionView($id) |
69 | 73 | { |
70 | - return $this->render('view', [ | |
71 | - 'model' => $this->findModel($id), | |
72 | - ]); | |
74 | + return $this->render( | |
75 | + 'view', | |
76 | + [ | |
77 | + 'model' => $this->findModel($id), | |
78 | + ] | |
79 | + ); | |
73 | 80 | } |
74 | 81 | |
75 | 82 | /** |
76 | 83 | * Creates a new Seo model. |
77 | 84 | * If creation is successful, the browser will be redirected to the 'view' page. |
85 | + * | |
78 | 86 | * @return mixed |
79 | 87 | */ |
80 | 88 | public function actionCreate() |
... | ... | @@ -82,19 +90,24 @@ |
82 | 90 | $model = new Seo(); |
83 | 91 | $model->generateLangs(); |
84 | 92 | |
85 | - if($model->load(Yii::$app->request->post())) { | |
93 | + if ($model->load(Yii::$app->request->post())) { | |
86 | 94 | $model->loadLangs(\Yii::$app->request); |
87 | - if($model->save() && $model->transactionStatus) { | |
88 | - return $this->redirect([ | |
89 | - 'view', | |
90 | - 'id' => $model->seo_id, | |
91 | - ]); | |
95 | + if ($model->save() && $model->transactionStatus) { | |
96 | + return $this->redirect( | |
97 | + [ | |
98 | + 'view', | |
99 | + 'id' => $model->id, | |
100 | + ] | |
101 | + ); | |
92 | 102 | } |
93 | 103 | } |
94 | - return $this->render('create', [ | |
95 | - 'model' => $model, | |
96 | - 'modelLangs' => $model->modelLangs, | |
97 | - ]); | |
104 | + return $this->render( | |
105 | + 'create', | |
106 | + [ | |
107 | + 'model' => $model, | |
108 | + 'modelLangs' => $model->modelLangs, | |
109 | + ] | |
110 | + ); | |
98 | 111 | } |
99 | 112 | |
100 | 113 | /** |
... | ... | @@ -109,19 +122,24 @@ |
109 | 122 | { |
110 | 123 | $model = $this->findModel($id); |
111 | 124 | $model->generateLangs(); |
112 | - if($model->load(Yii::$app->request->post())) { | |
125 | + if ($model->load(Yii::$app->request->post())) { | |
113 | 126 | $model->loadLangs(\Yii::$app->request); |
114 | - if($model->save() && $model->transactionStatus) { | |
115 | - return $this->redirect([ | |
116 | - 'view', | |
117 | - 'id' => $model->seo_id, | |
118 | - ]); | |
127 | + if ($model->save() && $model->transactionStatus) { | |
128 | + return $this->redirect( | |
129 | + [ | |
130 | + 'view', | |
131 | + 'id' => $model->id, | |
132 | + ] | |
133 | + ); | |
119 | 134 | } |
120 | 135 | } |
121 | - return $this->render('update', [ | |
122 | - 'model' => $model, | |
123 | - 'modelLangs' => $model->modelLangs, | |
124 | - ]); | |
136 | + return $this->render( | |
137 | + 'update', | |
138 | + [ | |
139 | + 'model' => $model, | |
140 | + 'modelLangs' => $model->modelLangs, | |
141 | + ] | |
142 | + ); | |
125 | 143 | } |
126 | 144 | |
127 | 145 | /** |
... | ... | @@ -151,10 +169,10 @@ |
151 | 169 | */ |
152 | 170 | protected function findModel($id) |
153 | 171 | { |
154 | - if(( $model = Seo::find() | |
155 | - ->where([ 'seo_id' => $id ]) | |
156 | - ->with('lang') | |
157 | - ->one() ) !== NULL | |
172 | + if (( $model = Seo::find() | |
173 | + ->where([ 'id' => $id ]) | |
174 | + ->with('lang') | |
175 | + ->one() ) !== null | |
158 | 176 | ) { |
159 | 177 | return $model; |
160 | 178 | } else { | ... | ... |
backend/controllers/SeoDynamicController.php
... | ... | @@ -57,11 +57,14 @@ |
57 | 57 | $searchModel = new SeoDynamicSearch(); |
58 | 58 | $dataProvider = $searchModel->search($seo_category_id, Yii::$app->request->queryParams); |
59 | 59 | |
60 | - return $this->render('index', [ | |
61 | - 'searchModel' => $searchModel, | |
62 | - 'dataProvider' => $dataProvider, | |
63 | - 'seo_category' => $seo_category, | |
64 | - ]); | |
60 | + return $this->render( | |
61 | + 'index', | |
62 | + [ | |
63 | + 'searchModel' => $searchModel, | |
64 | + 'dataProvider' => $dataProvider, | |
65 | + 'seo_category' => $seo_category, | |
66 | + ] | |
67 | + ); | |
65 | 68 | } |
66 | 69 | |
67 | 70 | /** |
... | ... | @@ -75,10 +78,13 @@ |
75 | 78 | public function actionView($seo_category_id, $id) |
76 | 79 | { |
77 | 80 | $seo_category = $this->findCategory($seo_category_id); |
78 | - return $this->render('view', [ | |
79 | - 'model' => $this->findModel($id), | |
80 | - 'seo_category' => $seo_category, | |
81 | - ]); | |
81 | + return $this->render( | |
82 | + 'view', | |
83 | + [ | |
84 | + 'model' => $this->findModel($id), | |
85 | + 'seo_category' => $seo_category, | |
86 | + ] | |
87 | + ); | |
82 | 88 | } |
83 | 89 | |
84 | 90 | /** |
... | ... | @@ -94,21 +100,26 @@ |
94 | 100 | $seo_category = $this->findCategory($seo_category_id); |
95 | 101 | $model = new SeoDynamic(); |
96 | 102 | $model->generateLangs(); |
97 | - if($model->load(Yii::$app->request->post())) { | |
103 | + if ($model->load(Yii::$app->request->post())) { | |
98 | 104 | $model->loadLangs(\Yii::$app->request); |
99 | 105 | $model->seo_category_id = $seo_category_id; |
100 | - if($model->save() && $model->transactionStatus) { | |
101 | - return $this->redirect([ | |
102 | - 'index', | |
103 | - 'seo_category_id' => $seo_category_id, | |
104 | - ]); | |
106 | + if ($model->save() && $model->transactionStatus) { | |
107 | + return $this->redirect( | |
108 | + [ | |
109 | + 'index', | |
110 | + 'seo_category_id' => $seo_category_id, | |
111 | + ] | |
112 | + ); | |
105 | 113 | } |
106 | 114 | } |
107 | - return $this->render('create', [ | |
108 | - 'model' => $model, | |
109 | - 'modelLangs' => $model->modelLangs, | |
110 | - 'seo_category' => $seo_category, | |
111 | - ]); | |
115 | + return $this->render( | |
116 | + 'create', | |
117 | + [ | |
118 | + 'model' => $model, | |
119 | + 'modelLangs' => $model->modelLangs, | |
120 | + 'seo_category' => $seo_category, | |
121 | + ] | |
122 | + ); | |
112 | 123 | } |
113 | 124 | |
114 | 125 | /** |
... | ... | @@ -125,20 +136,25 @@ |
125 | 136 | $seo_category = $this->findCategory($seo_category_id); |
126 | 137 | $model = $this->findModel($id); |
127 | 138 | $model->generateLangs(); |
128 | - if($model->load(Yii::$app->request->post())) { | |
139 | + if ($model->load(Yii::$app->request->post())) { | |
129 | 140 | $model->loadLangs(\Yii::$app->request); |
130 | - if($model->save() && $model->transactionStatus) { | |
131 | - return $this->redirect([ | |
132 | - 'index', | |
133 | - 'seo_category_id' => $seo_category_id, | |
134 | - ]); | |
141 | + if ($model->save() && $model->transactionStatus) { | |
142 | + return $this->redirect( | |
143 | + [ | |
144 | + 'index', | |
145 | + 'seo_category_id' => $seo_category_id, | |
146 | + ] | |
147 | + ); | |
135 | 148 | } |
136 | 149 | } |
137 | - return $this->render('update', [ | |
138 | - 'model' => $model, | |
139 | - 'modelLangs' => $model->modelLangs, | |
140 | - 'seo_category' => $seo_category, | |
141 | - ]); | |
150 | + return $this->render( | |
151 | + 'update', | |
152 | + [ | |
153 | + 'model' => $model, | |
154 | + 'modelLangs' => $model->modelLangs, | |
155 | + 'seo_category' => $seo_category, | |
156 | + ] | |
157 | + ); | |
142 | 158 | } |
143 | 159 | |
144 | 160 | /** |
... | ... | @@ -155,10 +171,12 @@ |
155 | 171 | $this->findModel($id) |
156 | 172 | ->delete(); |
157 | 173 | |
158 | - return $this->redirect([ | |
159 | - 'index', | |
160 | - 'seo_category_id' => $seo_category_id, | |
161 | - ]); | |
174 | + return $this->redirect( | |
175 | + [ | |
176 | + 'index', | |
177 | + 'seo_category_id' => $seo_category_id, | |
178 | + ] | |
179 | + ); | |
162 | 180 | } |
163 | 181 | |
164 | 182 | /** |
... | ... | @@ -172,10 +190,10 @@ |
172 | 190 | */ |
173 | 191 | protected function findModel($id) |
174 | 192 | { |
175 | - if(( $model = SeoDynamic::find() | |
176 | - ->where([ 'seo_dynamic_id' => $id ]) | |
177 | - ->with('lang') | |
178 | - ->one() ) !== NULL | |
193 | + if (( $model = SeoDynamic::find() | |
194 | + ->where([ 'id' => $id ]) | |
195 | + ->with('lang') | |
196 | + ->one() ) !== null | |
179 | 197 | ) { |
180 | 198 | return $model; |
181 | 199 | } else { |
... | ... | @@ -185,10 +203,10 @@ |
185 | 203 | |
186 | 204 | protected function findCategory($id) |
187 | 205 | { |
188 | - if(( $model = SeoCategory::find() | |
189 | - ->where([ 'seo_category_id' => $id ]) | |
190 | - ->with('lang') | |
191 | - ->one() ) !== NULL | |
206 | + if (( $model = SeoCategory::find() | |
207 | + ->where([ 'id' => $id ]) | |
208 | + ->with('lang') | |
209 | + ->one() ) !== null | |
192 | 210 | ) { |
193 | 211 | return $model; |
194 | 212 | } else { | ... | ... |
backend/controllers/ServiceController.php
... | ... | @@ -47,6 +47,7 @@ |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Lists all Service models. |
50 | + * | |
50 | 51 | * @return mixed |
51 | 52 | */ |
52 | 53 | public function actionIndex() |
... | ... | @@ -54,10 +55,13 @@ |
54 | 55 | $searchModel = new ServiceSearch(); |
55 | 56 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); |
56 | 57 | |
57 | - return $this->render('index', [ | |
58 | - 'searchModel' => $searchModel, | |
59 | - 'dataProvider' => $dataProvider, | |
60 | - ]); | |
58 | + return $this->render( | |
59 | + 'index', | |
60 | + [ | |
61 | + 'searchModel' => $searchModel, | |
62 | + 'dataProvider' => $dataProvider, | |
63 | + ] | |
64 | + ); | |
61 | 65 | } |
62 | 66 | |
63 | 67 | /** |
... | ... | @@ -69,33 +73,42 @@ |
69 | 73 | */ |
70 | 74 | public function actionView($id) |
71 | 75 | { |
72 | - return $this->render('view', [ | |
73 | - 'model' => $this->findModel($id), | |
74 | - ]); | |
76 | + return $this->render( | |
77 | + 'view', | |
78 | + [ | |
79 | + 'model' => $this->findModel($id), | |
80 | + ] | |
81 | + ); | |
75 | 82 | } |
76 | 83 | |
77 | 84 | /** |
78 | 85 | * Creates a new Service model. |
79 | 86 | * If creation is successful, the browser will be redirected to the 'view' page. |
87 | + * | |
80 | 88 | * @return mixed |
81 | 89 | */ |
82 | 90 | public function actionCreate() |
83 | 91 | { |
84 | 92 | $model = new Service(); |
85 | 93 | $model->generateLangs(); |
86 | - if($model->load(Yii::$app->request->post())) { | |
94 | + if ($model->load(Yii::$app->request->post())) { | |
87 | 95 | $model->loadLangs(\Yii::$app->request); |
88 | - if($model->save() && $model->transactionStatus) { | |
89 | - return $this->redirect([ | |
90 | - 'view', | |
91 | - 'id' => $model->service_id, | |
92 | - ]); | |
96 | + if ($model->save() && $model->transactionStatus) { | |
97 | + return $this->redirect( | |
98 | + [ | |
99 | + 'view', | |
100 | + 'id' => $model->id, | |
101 | + ] | |
102 | + ); | |
93 | 103 | } |
94 | 104 | } |
95 | - return $this->render('create', [ | |
96 | - 'model' => $model, | |
97 | - 'modelLangs' => $model->modelLangs, | |
98 | - ]); | |
105 | + return $this->render( | |
106 | + 'create', | |
107 | + [ | |
108 | + 'model' => $model, | |
109 | + 'modelLangs' => $model->modelLangs, | |
110 | + ] | |
111 | + ); | |
99 | 112 | } |
100 | 113 | |
101 | 114 | /** |
... | ... | @@ -111,19 +124,24 @@ |
111 | 124 | $model = $this->findModel($id); |
112 | 125 | $model->generateLangs(); |
113 | 126 | |
114 | - if($model->load(Yii::$app->request->post())) { | |
127 | + if ($model->load(Yii::$app->request->post())) { | |
115 | 128 | $model->loadLangs(\Yii::$app->request); |
116 | - if($model->save() && $model->transactionStatus) { | |
117 | - return $this->redirect([ | |
118 | - 'view', | |
119 | - 'id' => $model->service_id, | |
120 | - ]); | |
129 | + if ($model->save() && $model->transactionStatus) { | |
130 | + return $this->redirect( | |
131 | + [ | |
132 | + 'view', | |
133 | + 'id' => $model->id, | |
134 | + ] | |
135 | + ); | |
121 | 136 | } |
122 | 137 | } |
123 | - return $this->render('update', [ | |
124 | - 'model' => $model, | |
125 | - 'modelLangs' => $model->modelLangs, | |
126 | - ]); | |
138 | + return $this->render( | |
139 | + 'update', | |
140 | + [ | |
141 | + 'model' => $model, | |
142 | + 'modelLangs' => $model->modelLangs, | |
143 | + ] | |
144 | + ); | |
127 | 145 | } |
128 | 146 | |
129 | 147 | /** |
... | ... | @@ -153,7 +171,7 @@ |
153 | 171 | */ |
154 | 172 | protected function findModel($id) |
155 | 173 | { |
156 | - if(( $model = Service::findOne($id) ) !== NULL) { | |
174 | + if (( $model = Service::findOne($id) ) !== null) { | |
157 | 175 | return $model; |
158 | 176 | } else { |
159 | 177 | throw new NotFoundHttpException('The requested page does not exist.'); | ... | ... |
backend/controllers/SliderController.php
1 | 1 | <?php |
2 | - | |
3 | -namespace backend\controllers; | |
4 | - | |
5 | -use Yii; | |
6 | -use common\models\Slider; | |
7 | -use common\models\SliderSearch; | |
8 | -use yii\db\ActiveQuery; | |
9 | -use yii\web\Controller; | |
10 | -use yii\web\NotFoundHttpException; | |
11 | -use yii\filters\VerbFilter; | |
12 | -use developeruz\db_rbac\behaviors\AccessBehavior; | |
13 | -/** | |
14 | - * SliderController implements the CRUD actions for Slider model. | |
15 | - */ | |
16 | -class SliderController extends Controller | |
17 | -{ | |
2 | + | |
3 | + namespace backend\controllers; | |
4 | + | |
5 | + use Yii; | |
6 | + use common\models\Slider; | |
7 | + use common\models\SliderSearch; | |
8 | + use yii\db\ActiveQuery; | |
9 | + use yii\web\Controller; | |
10 | + use yii\web\NotFoundHttpException; | |
11 | + use yii\filters\VerbFilter; | |
12 | + use developeruz\db_rbac\behaviors\AccessBehavior; | |
13 | + | |
18 | 14 | /** |
19 | - * @inheritdoc | |
15 | + * SliderController implements the CRUD actions for Slider model. | |
20 | 16 | */ |
21 | - public function behaviors() | |
17 | + class SliderController extends Controller | |
22 | 18 | { |
23 | - return [ | |
24 | - 'access'=>[ | |
25 | - 'class' => AccessBehavior::className(), | |
26 | - 'rules' => | |
27 | - ['site' => | |
28 | - [ | |
19 | + /** | |
20 | + * @inheritdoc | |
21 | + */ | |
22 | + public function behaviors() | |
23 | + { | |
24 | + return [ | |
25 | + 'access' => [ | |
26 | + 'class' => AccessBehavior::className(), | |
27 | + 'rules' => [ | |
28 | + 'site' => [ | |
29 | 29 | [ |
30 | - 'actions' => ['login', 'error'], | |
31 | - 'allow' => true, | |
32 | - ] | |
33 | - ] | |
34 | - ] | |
35 | - ], | |
36 | - 'verbs' => [ | |
37 | - 'class' => VerbFilter::className(), | |
38 | - 'actions' => [ | |
39 | - 'delete' => ['POST'], | |
30 | + 'actions' => [ | |
31 | + 'login', | |
32 | + 'error', | |
33 | + ], | |
34 | + 'allow' => true, | |
35 | + ], | |
36 | + ], | |
37 | + ], | |
40 | 38 | ], |
41 | - ], | |
42 | - ]; | |
43 | - } | |
44 | - | |
45 | - /** | |
46 | - * Lists all Slider models. | |
47 | - * @return mixed | |
48 | - */ | |
49 | - public function actionIndex() | |
50 | - { | |
51 | - $searchModel = new SliderSearch(); | |
52 | - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |
39 | + 'verbs' => [ | |
40 | + 'class' => VerbFilter::className(), | |
41 | + 'actions' => [ | |
42 | + 'delete' => [ 'POST' ], | |
43 | + ], | |
44 | + ], | |
45 | + ]; | |
46 | + } | |
47 | + | |
53 | 48 | /** |
54 | - * @var ActiveQuery $query | |
49 | + * Lists all Slider models. | |
50 | + * | |
51 | + * @return mixed | |
55 | 52 | */ |
56 | - $query = $dataProvider->query; | |
57 | - $query->with('sliderImage'); | |
58 | - | |
59 | - return $this->render('index', [ | |
60 | - 'searchModel' => $searchModel, | |
61 | - 'dataProvider' => $dataProvider, | |
62 | - ]); | |
63 | - } | |
64 | - | |
65 | - /** | |
66 | - * Creates a new Slider model. | |
67 | - * If creation is successful, the browser will be redirected to the 'view' page. | |
68 | - * @return mixed | |
69 | - */ | |
70 | - public function actionCreate() | |
71 | - { | |
72 | - $model = new Slider(); | |
73 | - | |
74 | - if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
75 | - return $this->redirect(['view', 'id' => $model->slider_id]); | |
76 | - } else { | |
77 | - | |
78 | - | |
79 | - return $this->render('create', [ | |
80 | - 'model' => $model, | |
81 | - ]); | |
53 | + public function actionIndex() | |
54 | + { | |
55 | + $searchModel = new SliderSearch(); | |
56 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |
57 | + /** | |
58 | + * @var ActiveQuery $query | |
59 | + */ | |
60 | + $query = $dataProvider->query; | |
61 | + $query->with('sliderImage'); | |
62 | + | |
63 | + return $this->render( | |
64 | + 'index', | |
65 | + [ | |
66 | + 'searchModel' => $searchModel, | |
67 | + 'dataProvider' => $dataProvider, | |
68 | + ] | |
69 | + ); | |
82 | 70 | } |
83 | - } | |
84 | - | |
85 | - /** | |
86 | - * Updates an existing Slider model. | |
87 | - * If update is successful, the browser will be redirected to the 'view' page. | |
88 | - * @param integer $id | |
89 | - * @return mixed | |
90 | - */ | |
91 | - public function actionUpdate($id) | |
92 | - { | |
93 | - $model = $this->findModel($id); | |
94 | - | |
95 | - if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
96 | - return $this->redirect(['view', 'id' => $model->slider_id]); | |
97 | - } else { | |
98 | - return $this->render('update', [ | |
99 | - 'model' => $model, | |
100 | - ]); | |
71 | + | |
72 | + /** | |
73 | + * Creates a new Slider model. | |
74 | + * If creation is successful, the browser will be redirected to the 'view' page. | |
75 | + * | |
76 | + * @return mixed | |
77 | + */ | |
78 | + public function actionCreate() | |
79 | + { | |
80 | + $model = new Slider(); | |
81 | + | |
82 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
83 | + return $this->redirect( | |
84 | + [ | |
85 | + 'view', | |
86 | + 'id' => $model->id, | |
87 | + ] | |
88 | + ); | |
89 | + } else { | |
90 | + | |
91 | + return $this->render( | |
92 | + 'create', | |
93 | + [ | |
94 | + 'model' => $model, | |
95 | + ] | |
96 | + ); | |
97 | + } | |
101 | 98 | } |
102 | - } | |
103 | - | |
104 | - /** | |
105 | - * Deletes an existing Slider model. | |
106 | - * If deletion is successful, the browser will be redirected to the 'index' page. | |
107 | - * @param integer $id | |
108 | - * @return mixed | |
109 | - */ | |
110 | - public function actionDelete($id) | |
111 | - { | |
112 | - $this->findModel($id)->delete(); | |
113 | - | |
114 | - return $this->redirect(['index']); | |
115 | - } | |
116 | - | |
117 | - /** | |
118 | - * Finds the Slider model based on its primary key value. | |
119 | - * If the model is not found, a 404 HTTP exception will be thrown. | |
120 | - * @param integer $id | |
121 | - * @return Slider the loaded model | |
122 | - * @throws NotFoundHttpException if the model cannot be found | |
123 | - */ | |
124 | - protected function findModel($id) | |
125 | - { | |
126 | - if (($model = Slider::findOne($id)) !== null) { | |
127 | - return $model; | |
128 | - } else { | |
129 | - throw new NotFoundHttpException('The requested page does not exist.'); | |
99 | + | |
100 | + /** | |
101 | + * Updates an existing Slider model. | |
102 | + * If update is successful, the browser will be redirected to the 'view' page. | |
103 | + * | |
104 | + * @param integer $id | |
105 | + * | |
106 | + * @return mixed | |
107 | + */ | |
108 | + public function actionUpdate($id) | |
109 | + { | |
110 | + $model = $this->findModel($id); | |
111 | + | |
112 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
113 | + return $this->redirect( | |
114 | + [ | |
115 | + 'view', | |
116 | + 'id' => $model->id, | |
117 | + ] | |
118 | + ); | |
119 | + } else { | |
120 | + return $this->render( | |
121 | + 'update', | |
122 | + [ | |
123 | + 'model' => $model, | |
124 | + ] | |
125 | + ); | |
126 | + } | |
127 | + } | |
128 | + | |
129 | + /** | |
130 | + * Deletes an existing Slider model. | |
131 | + * If deletion is successful, the browser will be redirected to the 'index' page. | |
132 | + * | |
133 | + * @param integer $id | |
134 | + * | |
135 | + * @return mixed | |
136 | + */ | |
137 | + public function actionDelete($id) | |
138 | + { | |
139 | + $this->findModel($id) | |
140 | + ->delete(); | |
141 | + | |
142 | + return $this->redirect([ 'index' ]); | |
143 | + } | |
144 | + | |
145 | + /** | |
146 | + * Finds the Slider model based on its primary key value. | |
147 | + * If the model is not found, a 404 HTTP exception will be thrown. | |
148 | + * | |
149 | + * @param integer $id | |
150 | + * | |
151 | + * @return Slider the loaded model | |
152 | + * @throws NotFoundHttpException if the model cannot be found | |
153 | + */ | |
154 | + protected function findModel($id) | |
155 | + { | |
156 | + if (( $model = Slider::findOne($id) ) !== null) { | |
157 | + return $model; | |
158 | + } else { | |
159 | + throw new NotFoundHttpException('The requested page does not exist.'); | |
160 | + } | |
130 | 161 | } |
131 | 162 | } |
132 | -} | ... | ... |
backend/controllers/SliderImageController.php
... | ... | @@ -58,11 +58,14 @@ |
58 | 58 | $searchModel = new SliderImageSearch(); |
59 | 59 | $dataProvider = $searchModel->search($slider_id, Yii::$app->request->queryParams); |
60 | 60 | |
61 | - return $this->render('index', [ | |
62 | - 'slider_id' => $slider_id, | |
63 | - 'searchModel' => $searchModel, | |
64 | - 'dataProvider' => $dataProvider, | |
65 | - ]); | |
61 | + return $this->render( | |
62 | + 'index', | |
63 | + [ | |
64 | + 'slider_id' => $slider_id, | |
65 | + 'searchModel' => $searchModel, | |
66 | + 'dataProvider' => $dataProvider, | |
67 | + ] | |
68 | + ); | |
66 | 69 | } |
67 | 70 | |
68 | 71 | /** |
... | ... | @@ -75,10 +78,13 @@ |
75 | 78 | */ |
76 | 79 | public function actionView($slider_id, $id) |
77 | 80 | { |
78 | - return $this->render('view', [ | |
79 | - 'slider_id' => $slider_id, | |
80 | - 'model' => $this->findModel($slider_id, $id), | |
81 | - ]); | |
81 | + return $this->render( | |
82 | + 'view', | |
83 | + [ | |
84 | + 'slider_id' => $slider_id, | |
85 | + 'model' => $this->findModel($slider_id, $id), | |
86 | + ] | |
87 | + ); | |
82 | 88 | } |
83 | 89 | |
84 | 90 | /** |
... | ... | @@ -93,24 +99,29 @@ |
93 | 99 | { |
94 | 100 | $model = new SliderImage(); |
95 | 101 | $model->generateLangs(); |
96 | - if($model->load(Yii::$app->request->post())) { | |
102 | + if ($model->load(Yii::$app->request->post())) { | |
97 | 103 | $model->loadLangs(\Yii::$app->request); |
98 | 104 | $model->slider_id = $slider_id; |
99 | - if($model->save() && $model->transactionStatus) { | |
100 | - return $this->redirect([ | |
101 | - 'view', | |
102 | - 'slider_id' => $slider_id, | |
103 | - 'id' => $model->slider_image_id, | |
104 | - ]); | |
105 | + if ($model->save() && $model->transactionStatus) { | |
106 | + return $this->redirect( | |
107 | + [ | |
108 | + 'view', | |
109 | + 'slider_id' => $slider_id, | |
110 | + 'id' => $model->id, | |
111 | + ] | |
112 | + ); | |
105 | 113 | } |
106 | 114 | } |
107 | 115 | $slider = Slider::findOne($slider_id); |
108 | - return $this->render('create', [ | |
109 | - 'slider_id' => $slider_id, | |
110 | - 'model' => $model, | |
111 | - 'modelLangs' => $model->modelLangs, | |
112 | - 'slider' => $slider, | |
113 | - ]); | |
116 | + return $this->render( | |
117 | + 'create', | |
118 | + [ | |
119 | + 'slider_id' => $slider_id, | |
120 | + 'model' => $model, | |
121 | + 'modelLangs' => $model->modelLangs, | |
122 | + 'slider' => $slider, | |
123 | + ] | |
124 | + ); | |
114 | 125 | } |
115 | 126 | |
116 | 127 | /** |
... | ... | @@ -126,23 +137,28 @@ |
126 | 137 | { |
127 | 138 | $model = $this->findModel($slider_id, $id); |
128 | 139 | $model->generateLangs(); |
129 | - if($model->load(Yii::$app->request->post())) { | |
140 | + if ($model->load(Yii::$app->request->post())) { | |
130 | 141 | $model->loadLangs(\Yii::$app->request); |
131 | - if($model->save() && $model->transactionStatus) { | |
132 | - return $this->redirect([ | |
133 | - 'view', | |
134 | - 'slider_id' => $slider_id, | |
135 | - 'id' => $model->slider_image_id, | |
136 | - ]); | |
142 | + if ($model->save() && $model->transactionStatus) { | |
143 | + return $this->redirect( | |
144 | + [ | |
145 | + 'view', | |
146 | + 'slider_id' => $slider_id, | |
147 | + 'id' => $model->id, | |
148 | + ] | |
149 | + ); | |
137 | 150 | } |
138 | 151 | } |
139 | 152 | $slider = Slider::findOne($slider_id); |
140 | - return $this->render('update', [ | |
141 | - 'model' => $model, | |
142 | - 'modelLangs' => $model->modelLangs, | |
143 | - 'slider_id' => $slider_id, | |
144 | - 'slider' => $slider, | |
145 | - ]); | |
153 | + return $this->render( | |
154 | + 'update', | |
155 | + [ | |
156 | + 'model' => $model, | |
157 | + 'modelLangs' => $model->modelLangs, | |
158 | + 'slider_id' => $slider_id, | |
159 | + 'slider' => $slider, | |
160 | + ] | |
161 | + ); | |
146 | 162 | } |
147 | 163 | |
148 | 164 | /** |
... | ... | @@ -159,10 +175,12 @@ |
159 | 175 | $this->findModel($slider_id, $id) |
160 | 176 | ->delete(); |
161 | 177 | |
162 | - return $this->redirect([ | |
163 | - 'index', | |
164 | - 'slider_id' => $slider_id, | |
165 | - ]); | |
178 | + return $this->redirect( | |
179 | + [ | |
180 | + 'index', | |
181 | + 'slider_id' => $slider_id, | |
182 | + ] | |
183 | + ); | |
166 | 184 | } |
167 | 185 | |
168 | 186 | /** |
... | ... | @@ -180,12 +198,14 @@ |
180 | 198 | /** |
181 | 199 | * @var SliderImage $model |
182 | 200 | */ |
183 | - if(( $model = SliderImage::find() | |
184 | - ->where([ | |
185 | - 'slider_image_id' => $id, | |
186 | - 'slider_id' => $slider_id, | |
187 | - ]) | |
188 | - ->one() ) !== NULL | |
201 | + if (( $model = SliderImage::find() | |
202 | + ->where( | |
203 | + [ | |
204 | + 'id' => $id, | |
205 | + 'slider_id' => $slider_id, | |
206 | + ] | |
207 | + ) | |
208 | + ->one() ) !== null | |
189 | 209 | ) { |
190 | 210 | return $model; |
191 | 211 | } else { | ... | ... |
backend/models/OrderProducts.php
... | ... | @@ -41,6 +41,6 @@ |
41 | 41 | |
42 | 42 | public function getMod() |
43 | 43 | { |
44 | - return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ]); | |
44 | + return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]); | |
45 | 45 | } |
46 | 46 | } |
47 | 47 | \ No newline at end of file | ... | ... |
backend/views/seo-category/index.php
... | ... | @@ -19,32 +19,40 @@ |
19 | 19 | <p> |
20 | 20 | <?= Html::a(Yii::t('app', 'Create Seo Category'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> |
21 | 21 | </p> |
22 | - <?= GridView::widget([ | |
23 | - 'dataProvider' => $dataProvider, | |
24 | - 'filterModel' => $searchModel, | |
25 | - 'columns' => [ | |
26 | - [ 'class' => 'yii\grid\SerialColumn' ], | |
27 | - 'seo_category_id', | |
28 | - 'controller', | |
29 | - [ | |
30 | - 'attribute' => 'title', | |
31 | - 'value' => 'lang.title', | |
32 | - ], | |
33 | - 'status', | |
34 | - [ | |
35 | - 'class' => 'yii\grid\ActionColumn', | |
36 | - 'template' => '{update} {image} {delete}', | |
37 | - 'buttons' => [ | |
38 | - 'image' => function($url, $model) { | |
39 | - return Html::a('<span class="glyphicon glyphicon-picture"></span>', Url::toRoute([ | |
40 | - 'seo-dynamic/index', | |
41 | - 'seo_category_id' => $model->seo_category_id, | |
42 | - ]), [ | |
43 | - 'title' => \Yii::t('app', 'ัะปะฐะนะดั'), | |
44 | - ]); | |
45 | - }, | |
22 | + <?= GridView::widget( | |
23 | + [ | |
24 | + 'dataProvider' => $dataProvider, | |
25 | + 'filterModel' => $searchModel, | |
26 | + 'columns' => [ | |
27 | + [ 'class' => 'yii\grid\SerialColumn' ], | |
28 | + 'id', | |
29 | + 'controller', | |
30 | + [ | |
31 | + 'attribute' => 'title', | |
32 | + 'value' => 'lang.title', | |
33 | + ], | |
34 | + 'status', | |
35 | + [ | |
36 | + 'class' => 'yii\grid\ActionColumn', | |
37 | + 'template' => '{update} {image} {delete}', | |
38 | + 'buttons' => [ | |
39 | + 'image' => function ($url, $model) { | |
40 | + return Html::a( | |
41 | + '<span class="glyphicon glyphicon-picture"></span>', | |
42 | + Url::toRoute( | |
43 | + [ | |
44 | + 'seo-dynamic/index', | |
45 | + 'seo_category_id' => $model->id, | |
46 | + ] | |
47 | + ), | |
48 | + [ | |
49 | + 'title' => \Yii::t('app', 'ัะปะฐะนะดั'), | |
50 | + ] | |
51 | + ); | |
52 | + }, | |
53 | + ], | |
46 | 54 | ], |
47 | 55 | ], |
48 | - ], | |
49 | - ]); ?> | |
56 | + ] | |
57 | + ); ?> | |
50 | 58 | </div> | ... | ... |
backend/views/seo-category/update.php
backend/views/seo-dynamic/create.php
... | ... | @@ -23,7 +23,7 @@ |
23 | 23 | 'label' => $seo_category->lang->title, |
24 | 24 | 'url' => [ |
25 | 25 | 'index', |
26 | - 'seo_category_id' => $seo_category->seo_category_id, | |
26 | + 'seo_category_id' => $seo_category->id, | |
27 | 27 | ], |
28 | 28 | ]; |
29 | 29 | $this->params[ 'breadcrumbs' ][] = $this->title; |
... | ... | @@ -32,9 +32,12 @@ |
32 | 32 | |
33 | 33 | <h1><?= Html::encode($this->title) ?></h1> |
34 | 34 | |
35 | - <?= $this->render('_form', [ | |
36 | - 'model' => $model, | |
37 | - 'modelLangs' => $modelLangs, | |
38 | - ]) ?> | |
35 | + <?= $this->render( | |
36 | + '_form', | |
37 | + [ | |
38 | + 'model' => $model, | |
39 | + 'modelLangs' => $modelLangs, | |
40 | + ] | |
41 | + ) ?> | |
39 | 42 | |
40 | 43 | </div> | ... | ... |
backend/views/seo-dynamic/index.php
... | ... | @@ -11,9 +11,13 @@ |
11 | 11 | * @var yii\data\ActiveDataProvider $dataProvider |
12 | 12 | * @var SeoCategory $seo_category |
13 | 13 | */ |
14 | - $this->title = Yii::t('app', 'Seo Dynamics for {seo_category}', [ | |
15 | - 'seo_category' => $seo_category->lang->title, | |
16 | - ]); | |
14 | + $this->title = Yii::t( | |
15 | + 'app', | |
16 | + 'Seo Dynamics for {seo_category}', | |
17 | + [ | |
18 | + 'seo_category' => $seo_category->lang->title, | |
19 | + ] | |
20 | + ); | |
17 | 21 | $this->params[ 'breadcrumbs' ][] = [ |
18 | 22 | 'label' => \Yii::t('app', 'Seo Categories'), |
19 | 23 | 'url' => [ '/seo-category/index' ], |
... | ... | @@ -25,61 +29,83 @@ |
25 | 29 | <h1><?= Html::encode($this->title) ?></h1> |
26 | 30 | |
27 | 31 | <p> |
28 | - <?= Html::a(Yii::t('app', 'Create Seo Dynamic'), Url::toRoute([ | |
29 | - 'create', | |
30 | - 'seo_category_id' => $seo_category->seo_category_id, | |
31 | - ]), [ 'class' => 'btn btn-success' ]) ?> | |
32 | + <?= Html::a( | |
33 | + Yii::t('app', 'Create Seo Dynamic'), | |
34 | + Url::toRoute( | |
35 | + [ | |
36 | + 'create', | |
37 | + 'seo_category_id' => $seo_category->id, | |
38 | + ] | |
39 | + ), | |
40 | + [ 'class' => 'btn btn-success' ] | |
41 | + ) ?> | |
32 | 42 | </p> |
33 | - <?= GridView::widget([ | |
34 | - 'dataProvider' => $dataProvider, | |
35 | - 'filterModel' => $searchModel, | |
36 | - 'columns' => [ | |
37 | - [ 'class' => 'yii\grid\SerialColumn' ], | |
38 | - 'seo_dynamic_id', | |
39 | - [ | |
40 | - 'attribute' => 'title', | |
41 | - 'value' => 'lang.title', | |
42 | - ], | |
43 | - 'action', | |
44 | - 'fields', | |
45 | - 'param', | |
46 | - 'status', | |
47 | - [ | |
48 | - 'class' => 'yii\grid\ActionColumn', | |
49 | - 'buttons' => [ | |
50 | - 'view' => function($url, $model) { | |
51 | - return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', [ | |
52 | - 'view', | |
53 | - 'seo_category_id' => $model->seo_category_id, | |
54 | - 'id' => $model->seo_dynamic_id, | |
55 | - ], [ | |
56 | - 'title' => \Yii::t('app', 'ะัะพัะผะพัั'), | |
57 | - ]); | |
58 | - }, | |
59 | - 'update' => function($url, $model) { | |
60 | - return Html::a('<span class="glyphicon glyphicon-pencil"></span>', [ | |
61 | - 'update', | |
62 | - 'seo_category_id' => $model->seo_category_id, | |
63 | - 'id' => $model->seo_dynamic_id, | |
64 | - ], [ | |
65 | - 'title' => \Yii::t('app', 'ะ ะตะดะฐะบัะธัะพะฒะฐัั'), | |
66 | - ]); | |
67 | - }, | |
68 | - 'delete' => function($url, $model) { | |
69 | - | |
70 | - return Html::a('<span class="glyphicon glyphicon-trash"></span>', Url::toRoute([ | |
71 | - 'delete', | |
72 | - 'seo_category_id' => $model->seo_category_id, | |
73 | - 'id' => $model->seo_dynamic_id, | |
74 | - ]), [ | |
75 | - 'title' => Yii::t('yii', 'Delete'), | |
76 | - 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), | |
77 | - 'data-method' => 'post', | |
78 | - ]); | |
79 | - | |
80 | - }, | |
43 | + <?= GridView::widget( | |
44 | + [ | |
45 | + 'dataProvider' => $dataProvider, | |
46 | + 'filterModel' => $searchModel, | |
47 | + 'columns' => [ | |
48 | + [ 'class' => 'yii\grid\SerialColumn' ], | |
49 | + 'id', | |
50 | + [ | |
51 | + 'attribute' => 'title', | |
52 | + 'value' => 'lang.title', | |
53 | + ], | |
54 | + 'action', | |
55 | + 'fields', | |
56 | + 'param', | |
57 | + 'status', | |
58 | + [ | |
59 | + 'class' => 'yii\grid\ActionColumn', | |
60 | + 'buttons' => [ | |
61 | + 'view' => function ($url, $model) { | |
62 | + return Html::a( | |
63 | + '<span class="glyphicon glyphicon-eye-open"></span>', | |
64 | + [ | |
65 | + 'view', | |
66 | + 'seo_category_id' => $model->id, | |
67 | + 'id' => $model->id, | |
68 | + ], | |
69 | + [ | |
70 | + 'title' => \Yii::t('app', 'ะัะพัะผะพัั'), | |
71 | + ] | |
72 | + ); | |
73 | + }, | |
74 | + 'update' => function ($url, $model) { | |
75 | + return Html::a( | |
76 | + '<span class="glyphicon glyphicon-pencil"></span>', | |
77 | + [ | |
78 | + 'update', | |
79 | + 'seo_category_id' => $model->seo_category_id, | |
80 | + 'id' => $model->id, | |
81 | + ], | |
82 | + [ | |
83 | + 'title' => \Yii::t('app', 'ะ ะตะดะฐะบัะธัะพะฒะฐัั'), | |
84 | + ] | |
85 | + ); | |
86 | + }, | |
87 | + 'delete' => function ($url, $model) { | |
88 | + | |
89 | + return Html::a( | |
90 | + '<span class="glyphicon glyphicon-trash"></span>', | |
91 | + Url::toRoute( | |
92 | + [ | |
93 | + 'delete', | |
94 | + 'seo_category_id' => $model->seo_category_id, | |
95 | + 'id' => $model->id, | |
96 | + ] | |
97 | + ), | |
98 | + [ | |
99 | + 'title' => Yii::t('yii', 'Delete'), | |
100 | + 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), | |
101 | + 'data-method' => 'post', | |
102 | + ] | |
103 | + ); | |
104 | + | |
105 | + }, | |
106 | + ], | |
81 | 107 | ], |
82 | 108 | ], |
83 | - ], | |
84 | - ]); ?> | |
109 | + ] | |
110 | + ); ?> | |
85 | 111 | </div> | ... | ... |
backend/views/seo-dynamic/update.php
... | ... | @@ -13,9 +13,13 @@ |
13 | 13 | * @var SeoCategory $seo_category |
14 | 14 | */ |
15 | 15 | |
16 | - $this->title = Yii::t('app', 'Update {modelClass}: ', [ | |
17 | - 'modelClass' => 'Seo Dynamic', | |
18 | - ]) . $model->lang->title; | |
16 | + $this->title = Yii::t( | |
17 | + 'app', | |
18 | + 'Update {modelClass}: ', | |
19 | + [ | |
20 | + 'modelClass' => 'Seo Dynamic', | |
21 | + ] | |
22 | + ) . $model->lang->title; | |
19 | 23 | $this->params[ 'breadcrumbs' ][] = [ |
20 | 24 | 'label' => Yii::t('app', 'Seo Categories'), |
21 | 25 | 'url' => [ '/seo-category/index' ], |
... | ... | @@ -24,15 +28,15 @@ |
24 | 28 | 'label' => $seo_category->lang->title, |
25 | 29 | 'url' => [ |
26 | 30 | 'index', |
27 | - 'seo_category_id' => $seo_category->seo_category_id, | |
31 | + 'seo_category_id' => $seo_category->id, | |
28 | 32 | ], |
29 | 33 | ]; |
30 | 34 | $this->params[ 'breadcrumbs' ][] = [ |
31 | 35 | 'label' => $model->lang->title, |
32 | 36 | 'url' => [ |
33 | 37 | 'view', |
34 | - 'seo_category_id' => $seo_category->seo_category_id, | |
35 | - 'id' => $model->seo_dynamic_id, | |
38 | + 'seo_category_id' => $seo_category->id, | |
39 | + 'id' => $model->id, | |
36 | 40 | ], |
37 | 41 | ]; |
38 | 42 | $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update'); |
... | ... | @@ -41,9 +45,12 @@ |
41 | 45 | |
42 | 46 | <h1><?= Html::encode($this->title) ?></h1> |
43 | 47 | |
44 | - <?= $this->render('_form', [ | |
45 | - 'model' => $model, | |
46 | - 'modelLangs' => $modelLangs, | |
47 | - ]) ?> | |
48 | + <?= $this->render( | |
49 | + '_form', | |
50 | + [ | |
51 | + 'model' => $model, | |
52 | + 'modelLangs' => $modelLangs, | |
53 | + ] | |
54 | + ) ?> | |
48 | 55 | |
49 | 56 | </div> | ... | ... |
backend/views/seo-dynamic/view.php
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | 'label' => $seo_category->lang->title, |
19 | 19 | 'url' => [ |
20 | 20 | 'index', |
21 | - 'seo_category_id' => $seo_category->seo_category_id, | |
21 | + 'seo_category_id' => $seo_category->id, | |
22 | 22 | ], |
23 | 23 | ]; |
24 | 24 | $this->params[ 'breadcrumbs' ][] = $this->title; |
... | ... | @@ -28,48 +28,61 @@ |
28 | 28 | <h1><?= Html::encode($this->title) ?></h1> |
29 | 29 | |
30 | 30 | <p> |
31 | - <?= Html::a(Yii::t('app', 'Update'), [ | |
32 | - 'update', | |
33 | - 'id' => $model->seo_dynamic_id, | |
34 | - 'seo_category_id' => $seo_category->seo_category_id, | |
35 | - ], [ 'class' => 'btn btn-primary' ]) ?> | |
36 | - <?= Html::a(Yii::t('app', 'Delete'), [ | |
37 | - 'delete', | |
38 | - 'id' => $model->seo_dynamic_id, | |
39 | - 'seo_category_id' => $seo_category->seo_category_id, | |
40 | - ], [ | |
41 | - 'class' => 'btn btn-danger', | |
42 | - 'data' => [ | |
43 | - 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | |
44 | - 'method' => 'post', | |
31 | + <?= Html::a( | |
32 | + Yii::t('app', 'Update'), | |
33 | + [ | |
34 | + 'update', | |
35 | + 'id' => $model->id, | |
36 | + 'seo_category_id' => $seo_category->id, | |
37 | + ], | |
38 | + [ 'class' => 'btn btn-primary' ] | |
39 | + ) ?> | |
40 | + <?= Html::a( | |
41 | + Yii::t('app', 'Delete'), | |
42 | + [ | |
43 | + 'delete', | |
44 | + 'id' => $model->id, | |
45 | + 'seo_category_id' => $seo_category->id, | |
45 | 46 | ], |
46 | - ]) ?> | |
47 | + [ | |
48 | + 'class' => 'btn btn-danger', | |
49 | + 'data' => [ | |
50 | + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | |
51 | + 'method' => 'post', | |
52 | + ], | |
53 | + ] | |
54 | + ) ?> | |
47 | 55 | </p> |
48 | 56 | |
49 | - <?= DetailView::widget([ | |
50 | - 'model' => $model, | |
51 | - 'attributes' => [ | |
52 | - 'seo_dynamic_id', | |
53 | - [ | |
54 | - 'label' => \Yii::t('app', 'Seo Category'), | |
55 | - 'value' => Html::a($seo_category->lang->title, [ | |
56 | - 'index', | |
57 | - 'seo_category_id' => $seo_category->seo_category_id, | |
58 | - ]), | |
59 | - 'format' => 'html', | |
57 | + <?= DetailView::widget( | |
58 | + [ | |
59 | + 'model' => $model, | |
60 | + 'attributes' => [ | |
61 | + 'id', | |
62 | + [ | |
63 | + 'label' => \Yii::t('app', 'Seo Category'), | |
64 | + 'value' => Html::a( | |
65 | + $seo_category->lang->title, | |
66 | + [ | |
67 | + 'index', | |
68 | + 'seo_category_id' => $seo_category->id, | |
69 | + ] | |
70 | + ), | |
71 | + 'format' => 'html', | |
72 | + ], | |
73 | + 'lang.title', | |
74 | + 'action', | |
75 | + 'fields', | |
76 | + 'param', | |
77 | + 'status', | |
78 | + 'lang.meta_title', | |
79 | + 'lang.h1', | |
80 | + 'lang.key', | |
81 | + 'lang.meta', | |
82 | + 'lang.meta_description', | |
83 | + 'lang.seo_text', | |
60 | 84 | ], |
61 | - 'lang.title', | |
62 | - 'action', | |
63 | - 'fields', | |
64 | - 'param', | |
65 | - 'status', | |
66 | - 'lang.meta_title', | |
67 | - 'lang.h1', | |
68 | - 'lang.key', | |
69 | - 'lang.meta', | |
70 | - 'lang.meta_description', | |
71 | - 'lang.seo_text', | |
72 | - ], | |
73 | - ]) ?> | |
85 | + ] | |
86 | + ) ?> | |
74 | 87 | |
75 | 88 | </div> | ... | ... |
backend/views/seo/index.php
... | ... | @@ -18,34 +18,36 @@ |
18 | 18 | <p> |
19 | 19 | <?= Html::a(Yii::t('app', 'Create Seo'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> |
20 | 20 | </p> |
21 | - <?= GridView::widget([ | |
22 | - 'dataProvider' => $dataProvider, | |
23 | - 'filterModel' => $searchModel, | |
24 | - 'columns' => [ | |
25 | - [ 'class' => 'yii\grid\SerialColumn' ], | |
26 | - 'seo_id', | |
27 | - 'url', | |
28 | - [ | |
29 | - 'attribute' => 'title', | |
30 | - 'value' => 'lang.title', | |
21 | + <?= GridView::widget( | |
22 | + [ | |
23 | + 'dataProvider' => $dataProvider, | |
24 | + 'filterModel' => $searchModel, | |
25 | + 'columns' => [ | |
26 | + [ 'class' => 'yii\grid\SerialColumn' ], | |
27 | + 'id', | |
28 | + 'url', | |
29 | + [ | |
30 | + 'attribute' => 'title', | |
31 | + 'value' => 'lang.title', | |
32 | + ], | |
33 | + [ | |
34 | + 'attribute' => 'meta_description', | |
35 | + 'value' => 'lang.meta_description', | |
36 | + ], | |
37 | + [ | |
38 | + 'attribute' => 'h1', | |
39 | + 'value' => 'lang.h1', | |
40 | + ], | |
41 | + [ | |
42 | + 'attribute' => 'meta', | |
43 | + 'value' => 'lang.meta', | |
44 | + ], | |
45 | + [ | |
46 | + 'attribute' => 'seo_text', | |
47 | + 'value' => 'lang.seo_text', | |
48 | + ], | |
49 | + [ 'class' => 'yii\grid\ActionColumn' ], | |
31 | 50 | ], |
32 | - [ | |
33 | - 'attribute' => 'meta_description', | |
34 | - 'value' => 'lang.meta_description', | |
35 | - ], | |
36 | - [ | |
37 | - 'attribute' => 'h1', | |
38 | - 'value' => 'lang.h1', | |
39 | - ], | |
40 | - [ | |
41 | - 'attribute' => 'meta', | |
42 | - 'value' => 'lang.meta', | |
43 | - ], | |
44 | - [ | |
45 | - 'attribute' => 'seo_text', | |
46 | - 'value' => 'lang.seo_text', | |
47 | - ], | |
48 | - [ 'class' => 'yii\grid\ActionColumn' ], | |
49 | - ], | |
50 | - ]); ?> | |
51 | + ] | |
52 | + ); ?> | |
51 | 53 | </div> | ... | ... |
backend/views/seo/update.php
... | ... | @@ -11,9 +11,13 @@ |
11 | 11 | * @var SeoLang[] $modelLangs |
12 | 12 | */ |
13 | 13 | |
14 | - $this->title = Yii::t('app', 'Update {modelClass}: ', [ | |
15 | - 'modelClass' => 'Seo', | |
16 | - ]) . $model->url; | |
14 | + $this->title = Yii::t( | |
15 | + 'app', | |
16 | + 'Update {modelClass}: ', | |
17 | + [ | |
18 | + 'modelClass' => 'Seo', | |
19 | + ] | |
20 | + ) . $model->url; | |
17 | 21 | $this->params[ 'breadcrumbs' ][] = [ |
18 | 22 | 'label' => Yii::t('app', 'Seos'), |
19 | 23 | 'url' => [ 'index' ], |
... | ... | @@ -22,7 +26,7 @@ |
22 | 26 | 'label' => $model->url, |
23 | 27 | 'url' => [ |
24 | 28 | 'view', |
25 | - 'id' => $model->seo_id, | |
29 | + 'id' => $model->id, | |
26 | 30 | ], |
27 | 31 | ]; |
28 | 32 | $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update'); |
... | ... | @@ -31,9 +35,12 @@ |
31 | 35 | |
32 | 36 | <h1><?= Html::encode($this->title) ?></h1> |
33 | 37 | |
34 | - <?= $this->render('_form', [ | |
35 | - 'model' => $model, | |
36 | - 'modelLangs' => $modelLangs, | |
37 | - ]) ?> | |
38 | + <?= $this->render( | |
39 | + '_form', | |
40 | + [ | |
41 | + 'model' => $model, | |
42 | + 'modelLangs' => $modelLangs, | |
43 | + ] | |
44 | + ) ?> | |
38 | 45 | |
39 | 46 | </div> | ... | ... |
backend/views/seo/view.php
... | ... | @@ -19,33 +19,43 @@ |
19 | 19 | <h1><?= Html::encode($this->title) ?></h1> |
20 | 20 | |
21 | 21 | <p> |
22 | - <?= Html::a(Yii::t('app', 'Update'), [ | |
23 | - 'update', | |
24 | - 'id' => $model->seo_id, | |
25 | - ], [ 'class' => 'btn btn-primary' ]) ?> | |
26 | - <?= Html::a(Yii::t('app', 'Delete'), [ | |
27 | - 'delete', | |
28 | - 'id' => $model->seo_id, | |
29 | - ], [ | |
30 | - 'class' => 'btn btn-danger', | |
31 | - 'data' => [ | |
32 | - 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | |
33 | - 'method' => 'post', | |
22 | + <?= Html::a( | |
23 | + Yii::t('app', 'Update'), | |
24 | + [ | |
25 | + 'update', | |
26 | + 'id' => $model->id, | |
34 | 27 | ], |
35 | - ]) ?> | |
28 | + [ 'class' => 'btn btn-primary' ] | |
29 | + ) ?> | |
30 | + <?= Html::a( | |
31 | + Yii::t('app', 'Delete'), | |
32 | + [ | |
33 | + 'delete', | |
34 | + 'id' => $model->id, | |
35 | + ], | |
36 | + [ | |
37 | + 'class' => 'btn btn-danger', | |
38 | + 'data' => [ | |
39 | + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | |
40 | + 'method' => 'post', | |
41 | + ], | |
42 | + ] | |
43 | + ) ?> | |
36 | 44 | </p> |
37 | 45 | |
38 | - <?= DetailView::widget([ | |
39 | - 'model' => $model, | |
40 | - 'attributes' => [ | |
41 | - 'seo_id', | |
42 | - 'url', | |
43 | - 'lang.title', | |
44 | - 'lang.meta_description', | |
45 | - 'lang.h1', | |
46 | - 'lang.meta', | |
47 | - 'lang.seo_text', | |
48 | - ], | |
49 | - ]) ?> | |
46 | + <?= DetailView::widget( | |
47 | + [ | |
48 | + 'model' => $model, | |
49 | + 'attributes' => [ | |
50 | + 'id', | |
51 | + 'url', | |
52 | + 'lang.title', | |
53 | + 'lang.meta_description', | |
54 | + 'lang.h1', | |
55 | + 'lang.meta', | |
56 | + 'lang.seo_text', | |
57 | + ], | |
58 | + ] | |
59 | + ) ?> | |
50 | 60 | |
51 | 61 | </div> | ... | ... |
backend/views/service/index.php
... | ... | @@ -18,17 +18,19 @@ |
18 | 18 | <p> |
19 | 19 | <?= Html::a(Yii::t('app', 'Create Service'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> |
20 | 20 | </p> |
21 | - <?= GridView::widget([ | |
22 | - 'dataProvider' => $dataProvider, | |
23 | - 'filterModel' => $searchModel, | |
24 | - 'columns' => [ | |
25 | - [ 'class' => 'yii\grid\SerialColumn' ], | |
26 | - | |
27 | - 'service_id', | |
28 | - 'imageUrl:image', | |
29 | - 'created_at:date', | |
30 | - | |
31 | - [ 'class' => 'yii\grid\ActionColumn' ], | |
32 | - ], | |
33 | - ]); ?> | |
21 | + <?= GridView::widget( | |
22 | + [ | |
23 | + 'dataProvider' => $dataProvider, | |
24 | + 'filterModel' => $searchModel, | |
25 | + 'columns' => [ | |
26 | + [ 'class' => 'yii\grid\SerialColumn' ], | |
27 | + | |
28 | + 'id', | |
29 | + 'imageUrl:image', | |
30 | + 'created_at:date', | |
31 | + | |
32 | + [ 'class' => 'yii\grid\ActionColumn' ], | |
33 | + ], | |
34 | + ] | |
35 | + ); ?> | |
34 | 36 | </div> | ... | ... |
backend/views/service/update.php
... | ... | @@ -11,18 +11,22 @@ |
11 | 11 | * @var ServiceLang[] $modelLangs |
12 | 12 | */ |
13 | 13 | |
14 | - $this->title = Yii::t('app', 'Update {modelClass}: ', [ | |
15 | - 'modelClass' => 'Service', | |
16 | - ]) . $model->service_id; | |
14 | + $this->title = Yii::t( | |
15 | + 'app', | |
16 | + 'Update {modelClass}: ', | |
17 | + [ | |
18 | + 'modelClass' => 'Service', | |
19 | + ] | |
20 | + ) . $model->id; | |
17 | 21 | $this->params[ 'breadcrumbs' ][] = [ |
18 | 22 | 'label' => Yii::t('app', 'Services'), |
19 | 23 | 'url' => [ 'index' ], |
20 | 24 | ]; |
21 | 25 | $this->params[ 'breadcrumbs' ][] = [ |
22 | - 'label' => $model->service_id, | |
26 | + 'label' => $model->id, | |
23 | 27 | 'url' => [ |
24 | 28 | 'view', |
25 | - 'id' => $model->service_id, | |
29 | + 'id' => $model->id, | |
26 | 30 | ], |
27 | 31 | ]; |
28 | 32 | $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update'); |
... | ... | @@ -31,9 +35,12 @@ |
31 | 35 | |
32 | 36 | <h1><?= Html::encode($this->title) ?></h1> |
33 | 37 | |
34 | - <?= $this->render('_form', [ | |
35 | - 'model' => $model, | |
36 | - 'modelLangs' => $modelLangs, | |
37 | - ]) ?> | |
38 | + <?= $this->render( | |
39 | + '_form', | |
40 | + [ | |
41 | + 'model' => $model, | |
42 | + 'modelLangs' => $modelLangs, | |
43 | + ] | |
44 | + ) ?> | |
38 | 45 | |
39 | 46 | </div> | ... | ... |
backend/views/service/view.php
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | /* @var $this yii\web\View */ |
7 | 7 | /* @var $model common\models\Service */ |
8 | 8 | |
9 | - $this->title = $model->service_id; | |
9 | + $this->title = $model->id; | |
10 | 10 | $this->params[ 'breadcrumbs' ][] = [ |
11 | 11 | 'label' => Yii::t('app', 'Services'), |
12 | 12 | 'url' => [ 'index' ], |
... | ... | @@ -18,29 +18,39 @@ |
18 | 18 | <h1><?= Html::encode($this->title) ?></h1> |
19 | 19 | |
20 | 20 | <p> |
21 | - <?= Html::a(Yii::t('app', 'Update'), [ | |
22 | - 'update', | |
23 | - 'id' => $model->service_id, | |
24 | - ], [ 'class' => 'btn btn-primary' ]) ?> | |
25 | - <?= Html::a(Yii::t('app', 'Delete'), [ | |
26 | - 'delete', | |
27 | - 'id' => $model->service_id, | |
28 | - ], [ | |
29 | - 'class' => 'btn btn-danger', | |
30 | - 'data' => [ | |
31 | - 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | |
32 | - 'method' => 'post', | |
21 | + <?= Html::a( | |
22 | + Yii::t('app', 'Update'), | |
23 | + [ | |
24 | + 'update', | |
25 | + 'id' => $model->id, | |
33 | 26 | ], |
34 | - ]) ?> | |
27 | + [ 'class' => 'btn btn-primary' ] | |
28 | + ) ?> | |
29 | + <?= Html::a( | |
30 | + Yii::t('app', 'Delete'), | |
31 | + [ | |
32 | + 'delete', | |
33 | + 'id' => $model->id, | |
34 | + ], | |
35 | + [ | |
36 | + 'class' => 'btn btn-danger', | |
37 | + 'data' => [ | |
38 | + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | |
39 | + 'method' => 'post', | |
40 | + ], | |
41 | + ] | |
42 | + ) ?> | |
35 | 43 | </p> |
36 | 44 | |
37 | - <?= DetailView::widget([ | |
38 | - 'model' => $model, | |
39 | - 'attributes' => [ | |
40 | - 'service_id', | |
41 | - 'imageUrl:image', | |
42 | - 'created_at:date', | |
43 | - ], | |
44 | - ]) ?> | |
45 | + <?= DetailView::widget( | |
46 | + [ | |
47 | + 'model' => $model, | |
48 | + 'attributes' => [ | |
49 | + 'id', | |
50 | + 'imageUrl:image', | |
51 | + 'created_at:date', | |
52 | + ], | |
53 | + ] | |
54 | + ) ?> | |
45 | 55 | |
46 | 56 | </div> | ... | ... |
backend/views/slider-image/index.php
... | ... | @@ -23,66 +23,92 @@ |
23 | 23 | <h1><?= Html::encode($this->title) ?></h1> |
24 | 24 | |
25 | 25 | <p> |
26 | - <?= Html::a(Yii::t('app', 'Create Slider Image'), Url::toRoute([ | |
27 | - 'create', | |
28 | - 'slider_id' => $slider_id, | |
29 | - ]), [ 'class' => 'btn btn-success' ]) ?> | |
26 | + <?= Html::a( | |
27 | + Yii::t('app', 'Create Slider Image'), | |
28 | + Url::toRoute( | |
29 | + [ | |
30 | + 'create', | |
31 | + 'slider_id' => $slider_id, | |
32 | + ] | |
33 | + ), | |
34 | + [ 'class' => 'btn btn-success' ] | |
35 | + ) ?> | |
30 | 36 | </p> |
31 | - <?= GridView::widget([ | |
32 | - 'dataProvider' => $dataProvider, | |
33 | - 'filterModel' => $searchModel, | |
34 | - 'columns' => [ | |
35 | - 'slider_image_id', | |
36 | - 'imageUrl:image', | |
37 | - 'url', | |
38 | - [ | |
39 | - 'attribute' => 'status', | |
40 | - 'value' => function($model) { | |
41 | - /** | |
42 | - * @var SliderImage $model | |
43 | - */ | |
44 | - return ( !$model->status ) ? \Yii::t('app', 'ะกะบัััะพ') : \Yii::t('app', 'ะะพะบะฐะทะฐัั'); | |
45 | - }, | |
46 | - 'filter' => [ | |
47 | - 0 => \Yii::t('app', 'ะกะบัััะพ'), | |
48 | - 1 => \Yii::t('app', 'ะะพะบะฐะทะฐัั'), | |
49 | - ], | |
50 | - ], | |
51 | - [ | |
52 | - 'class' => 'yii\grid\ActionColumn', | |
53 | - 'buttons' => [ | |
54 | - 'view' => function($url, $model) { | |
55 | - return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', Url::toRoute([ | |
56 | - 'view', | |
57 | - 'slider_id' => $model->slider_id, | |
58 | - 'id' => $model->slider_image_id, | |
59 | - ]), [ | |
60 | - 'title' => \Yii::t('app', 'ะัะพัะผะพัั'), | |
61 | - ]); | |
62 | - }, | |
63 | - 'update' => function($url, $model) { | |
64 | - return Html::a('<span class="glyphicon glyphicon-pencil"></span>', Url::toRoute([ | |
65 | - 'update', | |
66 | - 'slider_id' => $model->slider_id, | |
67 | - 'id' => $model->slider_image_id, | |
68 | - ]), [ | |
69 | - 'title' => \Yii::t('app', 'ะ ะตะดะฐะบัะธัะพะฒะฐัั'), | |
70 | - ]); | |
71 | - }, | |
72 | - 'delete' => function($url, $model) { | |
73 | - return Html::a('<span class="glyphicon glyphicon-trash"></span>', Url::toRoute([ | |
74 | - 'delete', | |
75 | - 'slider_id' => $model->slider_id, | |
76 | - 'id' => $model->slider_image_id, | |
77 | - ]), [ | |
78 | - 'title' => Yii::t('yii', 'Delete'), | |
79 | - 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), | |
80 | - 'data-method' => 'post', | |
81 | - ]); | |
82 | - | |
37 | + <?= GridView::widget( | |
38 | + [ | |
39 | + 'dataProvider' => $dataProvider, | |
40 | + 'filterModel' => $searchModel, | |
41 | + 'columns' => [ | |
42 | + 'id', | |
43 | + 'imageUrl:image', | |
44 | + 'url', | |
45 | + [ | |
46 | + 'attribute' => 'status', | |
47 | + 'value' => function ($model) { | |
48 | + /** | |
49 | + * @var SliderImage $model | |
50 | + */ | |
51 | + return ( !$model->status ) ? \Yii::t('app', 'ะกะบัััะพ') : \Yii::t('app', 'ะะพะบะฐะทะฐัั'); | |
83 | 52 | }, |
53 | + 'filter' => [ | |
54 | + 0 => \Yii::t('app', 'ะกะบัััะพ'), | |
55 | + 1 => \Yii::t('app', 'ะะพะบะฐะทะฐัั'), | |
56 | + ], | |
57 | + ], | |
58 | + [ | |
59 | + 'class' => 'yii\grid\ActionColumn', | |
60 | + 'buttons' => [ | |
61 | + 'view' => function ($url, $model) { | |
62 | + return Html::a( | |
63 | + '<span class="glyphicon glyphicon-eye-open"></span>', | |
64 | + Url::toRoute( | |
65 | + [ | |
66 | + 'view', | |
67 | + 'slider_id' => $model->slider_id, | |
68 | + 'id' => $model->id, | |
69 | + ] | |
70 | + ), | |
71 | + [ | |
72 | + 'title' => \Yii::t('app', 'ะัะพัะผะพัั'), | |
73 | + ] | |
74 | + ); | |
75 | + }, | |
76 | + 'update' => function ($url, $model) { | |
77 | + return Html::a( | |
78 | + '<span class="glyphicon glyphicon-pencil"></span>', | |
79 | + Url::toRoute( | |
80 | + [ | |
81 | + 'update', | |
82 | + 'slider_id' => $model->slider_id, | |
83 | + 'id' => $model->id, | |
84 | + ] | |
85 | + ), | |
86 | + [ | |
87 | + 'title' => \Yii::t('app', 'ะ ะตะดะฐะบัะธัะพะฒะฐัั'), | |
88 | + ] | |
89 | + ); | |
90 | + }, | |
91 | + 'delete' => function ($url, $model) { | |
92 | + return Html::a( | |
93 | + '<span class="glyphicon glyphicon-trash"></span>', | |
94 | + Url::toRoute( | |
95 | + [ | |
96 | + 'delete', | |
97 | + 'slider_id' => $model->slider_id, | |
98 | + 'id' => $model->id, | |
99 | + ] | |
100 | + ), | |
101 | + [ | |
102 | + 'title' => Yii::t('yii', 'Delete'), | |
103 | + 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), | |
104 | + 'data-method' => 'post', | |
105 | + ] | |
106 | + ); | |
107 | + | |
108 | + }, | |
109 | + ], | |
84 | 110 | ], |
85 | 111 | ], |
86 | - ], | |
87 | - ]); ?> | |
112 | + ] | |
113 | + ); ?> | |
88 | 114 | </div> | ... | ... |
backend/views/slider-image/update.php
... | ... | @@ -15,29 +15,39 @@ |
15 | 15 | * @var int $slider_id |
16 | 16 | */ |
17 | 17 | |
18 | - $this->title = Yii::t('app', 'Update {modelClass}: ', [ | |
19 | - 'modelClass' => 'Slider Image', | |
20 | - ]) . $model->slider_image_id; | |
18 | + $this->title = Yii::t( | |
19 | + 'app', | |
20 | + 'Update {modelClass}: ', | |
21 | + [ | |
22 | + 'modelClass' => 'Slider Image', | |
23 | + ] | |
24 | + ) . $model->id; | |
21 | 25 | $this->params[ 'breadcrumbs' ][] = [ |
22 | 26 | 'label' => Yii::t('app', 'Sliders'), |
23 | - 'url' => Url::toRoute([ | |
24 | - 'slider/index', | |
25 | - ]), | |
27 | + 'url' => Url::toRoute( | |
28 | + [ | |
29 | + 'slider/index', | |
30 | + ] | |
31 | + ), | |
26 | 32 | ]; |
27 | 33 | $this->params[ 'breadcrumbs' ][] = [ |
28 | 34 | 'label' => Yii::t('app', 'Slider Images'), |
29 | - 'url' => Url::toRoute([ | |
30 | - 'index', | |
31 | - 'slider_id' => $slider_id, | |
32 | - ]), | |
35 | + 'url' => Url::toRoute( | |
36 | + [ | |
37 | + 'index', | |
38 | + 'slider_id' => $slider_id, | |
39 | + ] | |
40 | + ), | |
33 | 41 | ]; |
34 | 42 | $this->params[ 'breadcrumbs' ][] = [ |
35 | - 'label' => \Yii::t('app', 'Slide').': '.$model->slider_image_id, | |
36 | - 'url' => Url::toRoute([ | |
37 | - 'view', | |
38 | - 'slider_id' => $slider_id, | |
39 | - 'id' => $model->slider_image_id, | |
40 | - ]), | |
43 | + 'label' => \Yii::t('app', 'Slide') . ': ' . $model->id, | |
44 | + 'url' => Url::toRoute( | |
45 | + [ | |
46 | + 'view', | |
47 | + 'slider_id' => $slider_id, | |
48 | + 'id' => $model->id, | |
49 | + ] | |
50 | + ), | |
41 | 51 | ]; |
42 | 52 | $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update'); |
43 | 53 | ?> |
... | ... | @@ -45,10 +55,13 @@ |
45 | 55 | |
46 | 56 | <h1><?= Html::encode($this->title) ?></h1> |
47 | 57 | |
48 | - <?= $this->render('_form', [ | |
49 | - 'model' => $model, | |
50 | - 'modelLangs' => $modelLangs, | |
51 | - 'slider' => $slider, | |
52 | - ]) ?> | |
58 | + <?= $this->render( | |
59 | + '_form', | |
60 | + [ | |
61 | + 'model' => $model, | |
62 | + 'modelLangs' => $modelLangs, | |
63 | + 'slider' => $slider, | |
64 | + ] | |
65 | + ) ?> | |
53 | 66 | |
54 | 67 | </div> | ... | ... |
backend/views/slider-image/view.php
... | ... | @@ -9,19 +9,23 @@ |
9 | 9 | * @var common\models\SliderImage $model |
10 | 10 | * @var int $slider_id |
11 | 11 | */ |
12 | - $this->title = \Yii::t('app', 'Slide') . ': ' . $model->slider_image_id; | |
12 | + $this->title = \Yii::t('app', 'Slide') . ': ' . $model->id; | |
13 | 13 | $this->params[ 'breadcrumbs' ][] = [ |
14 | 14 | 'label' => Yii::t('app', 'Sliders'), |
15 | - 'url' => Url::toRoute([ | |
16 | - 'slider/index', | |
17 | - ]), | |
15 | + 'url' => Url::toRoute( | |
16 | + [ | |
17 | + 'slider/index', | |
18 | + ] | |
19 | + ), | |
18 | 20 | ]; |
19 | 21 | $this->params[ 'breadcrumbs' ][] = [ |
20 | 22 | 'label' => Yii::t('app', 'Slider Images'), |
21 | - 'url' => Url::toRoute([ | |
22 | - 'index', | |
23 | - 'slider_id' => $slider_id, | |
24 | - ]), | |
23 | + 'url' => Url::toRoute( | |
24 | + [ | |
25 | + 'index', | |
26 | + 'slider_id' => $slider_id, | |
27 | + ] | |
28 | + ), | |
25 | 29 | ]; |
26 | 30 | $this->params[ 'breadcrumbs' ][] = $this->title; |
27 | 31 | ?> |
... | ... | @@ -30,46 +34,59 @@ |
30 | 34 | <h1><?= Html::encode($this->title) ?></h1> |
31 | 35 | |
32 | 36 | <p> |
33 | - <?= Html::a(Yii::t('app', 'Update'), [ | |
34 | - 'update', | |
35 | - 'slider_id' => $slider_id, | |
36 | - 'id' => $model->slider_image_id, | |
37 | - ], [ 'class' => 'btn btn-primary' ]) ?> | |
38 | - <?= Html::a(Yii::t('app', 'Delete'), [ | |
39 | - 'delete', | |
40 | - 'slider_id' => $slider_id, | |
41 | - 'id' => $model->slider_image_id, | |
42 | - ], [ | |
43 | - 'class' => 'btn btn-danger', | |
44 | - 'data' => [ | |
45 | - 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | |
46 | - 'method' => 'post', | |
37 | + <?= Html::a( | |
38 | + Yii::t('app', 'Update'), | |
39 | + [ | |
40 | + 'update', | |
41 | + 'slider_id' => $slider_id, | |
42 | + 'id' => $model->id, | |
47 | 43 | ], |
48 | - ]) ?> | |
49 | - </p> | |
50 | - | |
51 | - <?= DetailView::widget([ | |
52 | - 'model' => $model, | |
53 | - 'attributes' => [ | |
54 | - 'slider_image_id', | |
44 | + [ 'class' => 'btn btn-primary' ] | |
45 | + ) ?> | |
46 | + <?= Html::a( | |
47 | + Yii::t('app', 'Delete'), | |
55 | 48 | [ |
56 | - 'attribute' => 'slider_id', | |
57 | - 'format' => 'html', | |
58 | - 'value' => Html::a($model->slider->title, [ | |
59 | - 'slider/update', | |
60 | - 'id' => $model->slider_id, | |
61 | - ]), | |
49 | + 'delete', | |
50 | + 'slider_id' => $slider_id, | |
51 | + 'id' => $model->id, | |
62 | 52 | ], |
63 | - 'lang.title', | |
64 | - 'lang.alt', | |
65 | - 'imageUrl:image', | |
66 | - 'url:url', | |
67 | 53 | [ |
68 | - 'attribute' => 'status', | |
69 | - 'value' => $model->status?\Yii::t('app', 'ะะพะบะฐะทะฐัั'):\Yii::t('app', 'ะกะบัััั'), | |
54 | + 'class' => 'btn btn-danger', | |
55 | + 'data' => [ | |
56 | + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | |
57 | + 'method' => 'post', | |
58 | + ], | |
59 | + ] | |
60 | + ) ?> | |
61 | + </p> | |
62 | + | |
63 | + <?= DetailView::widget( | |
64 | + [ | |
65 | + 'model' => $model, | |
66 | + 'attributes' => [ | |
67 | + 'id', | |
68 | + [ | |
69 | + 'attribute' => 'slider_id', | |
70 | + 'format' => 'html', | |
71 | + 'value' => Html::a( | |
72 | + $model->slider->title, | |
73 | + [ | |
74 | + 'slider/update', | |
75 | + 'id' => $model->slider_id, | |
76 | + ] | |
77 | + ), | |
78 | + ], | |
79 | + 'lang.title', | |
80 | + 'lang.alt', | |
81 | + 'imageUrl:image', | |
82 | + 'url:url', | |
83 | + [ | |
84 | + 'attribute' => 'status', | |
85 | + 'value' => $model->status ? \Yii::t('app', 'ะะพะบะฐะทะฐัั') : \Yii::t('app', 'ะกะบัััั'), | |
86 | + ], | |
87 | + 'sort', | |
70 | 88 | ], |
71 | - 'sort', | |
72 | - ], | |
73 | - ]) ?> | |
89 | + ] | |
90 | + ) ?> | |
74 | 91 | |
75 | 92 | </div> | ... | ... |
backend/views/slider/index.php
... | ... | @@ -20,48 +20,56 @@ |
20 | 20 | <p> |
21 | 21 | <?= Html::a(Yii::t('app', 'Create Slider'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> |
22 | 22 | </p> |
23 | - <?= GridView::widget([ | |
24 | - 'dataProvider' => $dataProvider, | |
25 | - 'filterModel' => $searchModel, | |
26 | - 'columns' => [ | |
27 | - 'slider_id', | |
28 | - 'title', | |
29 | - [ | |
30 | - 'attribute' => 'status', | |
31 | - 'value' => function($model) { | |
32 | - /** | |
33 | - * @var Slider $model | |
34 | - */ | |
35 | - return ( !$model->status ) ? \Yii::t('app', 'ะกะบัััะพ') : \Yii::t('app', 'ะะพะบะฐะทะฐัั'); | |
36 | - }, | |
37 | - 'filter' => [ | |
38 | - 0 => \Yii::t('app', 'ะกะบัััะพ'), | |
39 | - 1 => \Yii::t('app', 'ะะพะบะฐะทะฐัั'), | |
23 | + <?= GridView::widget( | |
24 | + [ | |
25 | + 'dataProvider' => $dataProvider, | |
26 | + 'filterModel' => $searchModel, | |
27 | + 'columns' => [ | |
28 | + 'id', | |
29 | + 'title', | |
30 | + [ | |
31 | + 'attribute' => 'status', | |
32 | + 'value' => function ($model) { | |
33 | + /** | |
34 | + * @var Slider $model | |
35 | + */ | |
36 | + return ( !$model->status ) ? \Yii::t('app', 'ะกะบัััะพ') : \Yii::t('app', 'ะะพะบะฐะทะฐัั'); | |
37 | + }, | |
38 | + 'filter' => [ | |
39 | + 0 => \Yii::t('app', 'ะกะบัััะพ'), | |
40 | + 1 => \Yii::t('app', 'ะะพะบะฐะทะฐัั'), | |
41 | + ], | |
40 | 42 | ], |
41 | - ], | |
42 | - [ | |
43 | - 'label' => \Yii::t('app', 'Slide count'), | |
44 | - 'content' => function($model) { | |
45 | - /** | |
46 | - * @var Slider $model | |
47 | - */ | |
43 | + [ | |
44 | + 'label' => \Yii::t('app', 'Slide count'), | |
45 | + 'content' => function ($model) { | |
46 | + /** | |
47 | + * @var Slider $model | |
48 | + */ | |
48 | 49 | return count($model->sliderImage); |
49 | - }, | |
50 | - ], | |
51 | - [ | |
52 | - 'class' => 'yii\grid\ActionColumn', | |
53 | - 'template' => '{update} {image} {delete}', | |
54 | - 'buttons' => [ | |
55 | - 'image' => function($url, $model) { | |
56 | - return Html::a('<span class="glyphicon glyphicon-picture"></span>', Url::toRoute([ | |
57 | - 'slider-image/index', | |
58 | - 'slider_id' => $model->slider_id, | |
59 | - ]), [ | |
60 | - 'title' => \Yii::t('app', "ัะปะฐะนะดั"), | |
61 | - ]); | |
62 | 50 | }, |
63 | 51 | ], |
52 | + [ | |
53 | + 'class' => 'yii\grid\ActionColumn', | |
54 | + 'template' => '{update} {image} {delete}', | |
55 | + 'buttons' => [ | |
56 | + 'image' => function ($url, $model) { | |
57 | + return Html::a( | |
58 | + '<span class="glyphicon glyphicon-picture"></span>', | |
59 | + Url::toRoute( | |
60 | + [ | |
61 | + 'slider-image/index', | |
62 | + 'slider_id' => $model->id, | |
63 | + ] | |
64 | + ), | |
65 | + [ | |
66 | + 'title' => \Yii::t('app', "ัะปะฐะนะดั"), | |
67 | + ] | |
68 | + ); | |
69 | + }, | |
70 | + ], | |
71 | + ], | |
64 | 72 | ], |
65 | - ], | |
66 | - ]); ?> | |
73 | + ] | |
74 | + ); ?> | |
67 | 75 | </div> | ... | ... |
common/models/Basket.php
... | ... | @@ -93,7 +93,7 @@ |
93 | 93 | * @var ProductVariant $model |
94 | 94 | */ |
95 | 95 | $model = ProductVariant::find() |
96 | - ->where([ 'product_variant.product_variant_id' => $product_variant_id ]) | |
96 | + ->where([ 'product_variant.id' => $product_variant_id ]) | |
97 | 97 | ->joinWith('lang', true, 'INNER JOIN') |
98 | 98 | ->one(); |
99 | 99 | if(empty( $model )) { |
... | ... | @@ -106,7 +106,7 @@ |
106 | 106 | public function findModels(array $product_variant_ids) |
107 | 107 | { |
108 | 108 | return ProductVariant::find() |
109 | - ->where([ 'product_variant.product_variant_id' => $product_variant_ids ]) | |
109 | + ->where([ 'product_variant.id' => $product_variant_ids ]) | |
110 | 110 | ->joinWith('lang', true, 'INNER JOIN') |
111 | 111 | ->with([ |
112 | 112 | 'product', | ... | ... |
common/models/Order.php
... | ... | @@ -217,7 +217,7 @@ |
217 | 217 | 'product.alias', |
218 | 218 | ] |
219 | 219 | ) |
220 | - ->where([ 'product_variant.product_variant_id' => $product[ 'id' ] ]) | |
220 | + ->where([ 'product_variant.id' => $product[ 'id' ] ]) | |
221 | 221 | ->leftJoin('product', 'product.id = product_variant.product_id') |
222 | 222 | ->one(); |
223 | 223 | $row->count = $product[ 'count' ]; |
... | ... | @@ -249,7 +249,7 @@ |
249 | 249 | * @var ProductVariant $mod |
250 | 250 | */ |
251 | 251 | $mod = ProductVariant::find() |
252 | - ->where([ 'product_variant_id' => $product_variant_id ]) | |
252 | + ->where([ 'id' => $product_variant_id ]) | |
253 | 253 | ->one(); |
254 | 254 | |
255 | 255 | return $mod->price; | ... | ... |
common/models/OrderProduct.php
... | ... | @@ -51,6 +51,6 @@ |
51 | 51 | |
52 | 52 | public function getProductVariant() |
53 | 53 | { |
54 | - return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ]); | |
54 | + return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]); | |
55 | 55 | } |
56 | 56 | } |
57 | 57 | \ No newline at end of file | ... | ... |
common/models/Seo.php
... | ... | @@ -10,7 +10,8 @@ |
10 | 10 | |
11 | 11 | /** |
12 | 12 | * This is the model class for table "seo". |
13 | - * @property integer $seo_id | |
13 | + * | |
14 | + * @property integer $id | |
14 | 15 | * @property string $url |
15 | 16 | * * From language behavior * |
16 | 17 | * @property SeoLang $lang |
... | ... | @@ -77,8 +78,8 @@ |
77 | 78 | public function attributeLabels() |
78 | 79 | { |
79 | 80 | return [ |
80 | - 'seo_id' => Yii::t('app', 'seo_id'), | |
81 | - 'url' => Yii::t('app', 'url'), | |
81 | + 'id' => Yii::t('app', 'seo_id'), | |
82 | + 'url' => Yii::t('app', 'url'), | |
82 | 83 | ]; |
83 | 84 | } |
84 | 85 | } | ... | ... |
common/models/SeoCategory.php
... | ... | @@ -10,7 +10,8 @@ |
10 | 10 | |
11 | 11 | /** |
12 | 12 | * This is the model class for table "seo_category". |
13 | - * @property integer $seo_category_id | |
13 | + * | |
14 | + * @property integer $id | |
14 | 15 | * @property string $controller |
15 | 16 | * @property integer $status |
16 | 17 | * * From language behavior * |
... | ... | @@ -79,9 +80,9 @@ |
79 | 80 | public function attributeLabels() |
80 | 81 | { |
81 | 82 | return [ |
82 | - 'seo_category_id' => Yii::t('app', 'seo_category_id'), | |
83 | - 'controller' => Yii::t('app', 'controller'), | |
84 | - 'status' => Yii::t('app', 'status'), | |
83 | + 'id' => Yii::t('app', 'seo_category_id'), | |
84 | + 'controller' => Yii::t('app', 'controller'), | |
85 | + 'status' => Yii::t('app', 'status'), | |
85 | 86 | ]; |
86 | 87 | } |
87 | 88 | |
... | ... | @@ -90,6 +91,6 @@ |
90 | 91 | */ |
91 | 92 | public function getSeoDynamics() |
92 | 93 | { |
93 | - return $this->hasMany(SeoDynamic::className(), [ 'seo_category_id' => 'seo_category_id' ]); | |
94 | + return $this->hasMany(SeoDynamic::className(), [ 'seo_category_id' => 'id' ]); | |
94 | 95 | } |
95 | 96 | } | ... | ... |
common/models/SeoCategoryLang.php
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This is the model class for table "seo_category_lang". |
11 | + * | |
11 | 12 | * @property integer $seo_category_id |
12 | 13 | * @property integer $language_id |
13 | 14 | * @property string $title |
... | ... | @@ -68,7 +69,7 @@ |
68 | 69 | 'exist', |
69 | 70 | 'skipOnError' => true, |
70 | 71 | 'targetClass' => SeoCategory::className(), |
71 | - 'targetAttribute' => [ 'seo_category_id' => 'seo_category_id' ], | |
72 | + 'targetAttribute' => [ 'seo_category_id' => 'id' ], | |
72 | 73 | ], |
73 | 74 | ]; |
74 | 75 | } |
... | ... | @@ -81,7 +82,7 @@ |
81 | 82 | return [ |
82 | 83 | 'seo_category_id' => Yii::t('app', 'seo_category_id'), |
83 | 84 | 'language_id' => Yii::t('app', 'language_id'), |
84 | - 'title' => Yii::t('app', 'name'), | |
85 | + 'title' => Yii::t('app', 'name'), | |
85 | 86 | ]; |
86 | 87 | } |
87 | 88 | |
... | ... | @@ -98,6 +99,6 @@ |
98 | 99 | */ |
99 | 100 | public function getSeoCategory() |
100 | 101 | { |
101 | - return $this->hasOne(SeoCategory::className(), [ 'seo_category_id' => 'seo_category_id' ]); | |
102 | + return $this->hasOne(SeoCategory::className(), [ 'id' => 'seo_category_id' ]); | |
102 | 103 | } |
103 | 104 | } | ... | ... |
common/models/SeoCategorySearch.php
... | ... | @@ -27,7 +27,7 @@ |
27 | 27 | return [ |
28 | 28 | [ |
29 | 29 | [ |
30 | - 'seo_category_id', | |
30 | + 'id', | |
31 | 31 | 'status', |
32 | 32 | ], |
33 | 33 | 'integer', |
... | ... | @@ -65,45 +65,53 @@ |
65 | 65 | |
66 | 66 | // add conditions that should always apply here |
67 | 67 | |
68 | - $dataProvider = new ActiveDataProvider([ | |
69 | - 'query' => $query, | |
70 | - 'sort' => [ | |
71 | - 'attributes' => [ | |
72 | - 'seo_category_id', | |
73 | - 'controller', | |
74 | - 'status', | |
75 | - 'title' => [ | |
76 | - 'asc' => [ 'seo_category_lang.title' => SORT_ASC ], | |
77 | - 'desc' => [ 'seo_category_lang.title' => SORT_DESC ], | |
68 | + $dataProvider = new ActiveDataProvider( | |
69 | + [ | |
70 | + 'query' => $query, | |
71 | + 'sort' => [ | |
72 | + 'attributes' => [ | |
73 | + 'id', | |
74 | + 'controller', | |
75 | + 'status', | |
76 | + 'title' => [ | |
77 | + 'asc' => [ 'seo_category_lang.title' => SORT_ASC ], | |
78 | + 'desc' => [ 'seo_category_lang.title' => SORT_DESC ], | |
79 | + ], | |
78 | 80 | ], |
79 | 81 | ], |
80 | - ], | |
81 | - ]); | |
82 | + ] | |
83 | + ); | |
82 | 84 | |
83 | 85 | $this->load($params); |
84 | 86 | |
85 | - if(!$this->validate()) { | |
87 | + if (!$this->validate()) { | |
86 | 88 | // uncomment the following line if you do not want to return any records when validation fails |
87 | 89 | // $query->where('0=1'); |
88 | 90 | return $dataProvider; |
89 | 91 | } |
90 | 92 | |
91 | 93 | // grid filtering conditions |
92 | - $query->andFilterWhere([ | |
93 | - 'seo_category_id' => $this->seo_category_id, | |
94 | - 'status' => $this->status, | |
95 | - ]); | |
94 | + $query->andFilterWhere( | |
95 | + [ | |
96 | + 'id' => $this->id, | |
97 | + 'status' => $this->status, | |
98 | + ] | |
99 | + ); | |
96 | 100 | |
97 | - $query->andFilterWhere([ | |
98 | - 'like', | |
99 | - 'controller', | |
100 | - $this->controller, | |
101 | - ]) | |
102 | - ->andFilterWhere([ | |
103 | - 'ilike', | |
104 | - 'seo_category_lang.title', | |
105 | - $this->title, | |
106 | - ]); | |
101 | + $query->andFilterWhere( | |
102 | + [ | |
103 | + 'like', | |
104 | + 'controller', | |
105 | + $this->controller, | |
106 | + ] | |
107 | + ) | |
108 | + ->andFilterWhere( | |
109 | + [ | |
110 | + 'ilike', | |
111 | + 'seo_category_lang.title', | |
112 | + $this->title, | |
113 | + ] | |
114 | + ); | |
107 | 115 | |
108 | 116 | return $dataProvider; |
109 | 117 | } | ... | ... |
common/models/SeoDynamic.php
... | ... | @@ -10,7 +10,8 @@ |
10 | 10 | |
11 | 11 | /** |
12 | 12 | * This is the model class for table "seo_dynamic". |
13 | - * @property integer $seo_dynamic_id | |
13 | + * | |
14 | + * @property integer $id | |
14 | 15 | * @property integer $seo_category_id |
15 | 16 | * @property string $action |
16 | 17 | * @property string $fields |
... | ... | @@ -91,7 +92,7 @@ |
91 | 92 | 'exist', |
92 | 93 | 'skipOnError' => true, |
93 | 94 | 'targetClass' => SeoCategory::className(), |
94 | - 'targetAttribute' => [ 'seo_category_id' => 'seo_category_id' ], | |
95 | + 'targetAttribute' => [ 'seo_category_id' => 'id' ], | |
95 | 96 | ], |
96 | 97 | ]; |
97 | 98 | } |
... | ... | @@ -102,7 +103,7 @@ |
102 | 103 | public function attributeLabels() |
103 | 104 | { |
104 | 105 | return [ |
105 | - 'seo_dynamic_id' => Yii::t('app', 'seo_dynamic_id'), | |
106 | + 'id' => Yii::t('app', 'seo_dynamic_id'), | |
106 | 107 | 'seo_category_id' => Yii::t('app', 'seo_category_id'), |
107 | 108 | 'action' => Yii::t('app', 'action'), |
108 | 109 | 'fields' => Yii::t('app', 'fields'), |
... | ... | @@ -116,6 +117,6 @@ |
116 | 117 | */ |
117 | 118 | public function getSeoCategory() |
118 | 119 | { |
119 | - return $this->hasOne(SeoCategory::className(), [ 'seo_category_id' => 'seo_category_id' ]); | |
120 | + return $this->hasOne(SeoCategory::className(), [ 'id' => 'seo_category_id' ]); | |
120 | 121 | } |
121 | 122 | } | ... | ... |
common/models/SeoDynamicLang.php
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This is the model class for table "seo_dynamic_lang". |
11 | + * | |
11 | 12 | * @property integer $seo_dynamic_id |
12 | 13 | * @property integer $language_id |
13 | 14 | * @property string $title |
... | ... | @@ -87,7 +88,7 @@ |
87 | 88 | 'exist', |
88 | 89 | 'skipOnError' => true, |
89 | 90 | 'targetClass' => SeoDynamic::className(), |
90 | - 'targetAttribute' => [ 'seo_dynamic_id' => 'seo_dynamic_id' ], | |
91 | + 'targetAttribute' => [ 'seo_dynamic_id' => 'id' ], | |
91 | 92 | ], |
92 | 93 | ]; |
93 | 94 | } |
... | ... | @@ -98,15 +99,15 @@ |
98 | 99 | public function attributeLabels() |
99 | 100 | { |
100 | 101 | return [ |
101 | - 'seo_dynamic_id' => Yii::t('app', 'seo_dynamic_id'), | |
102 | - 'language_id' => Yii::t('app', 'language_id'), | |
103 | - 'title' => Yii::t('app', 'name'), | |
104 | - 'meta_title' => Yii::t('app', 'title'), | |
105 | - 'h1' => Yii::t('app', 'h1'), | |
106 | - 'key' => Yii::t('app', 'key'), | |
107 | - 'meta' => Yii::t('app', 'meta'), | |
108 | - 'meta_description' => Yii::t('app', 'meta_description'), | |
109 | - 'seo_text' => Yii::t('app', 'seo_text'), | |
102 | + 'seo_dynamic_id' => Yii::t('app', 'seo_dynamic_id'), | |
103 | + 'language_id' => Yii::t('app', 'language_id'), | |
104 | + 'title' => Yii::t('app', 'name'), | |
105 | + 'meta_title' => Yii::t('app', 'title'), | |
106 | + 'h1' => Yii::t('app', 'h1'), | |
107 | + 'key' => Yii::t('app', 'key'), | |
108 | + 'meta' => Yii::t('app', 'meta'), | |
109 | + 'meta_description' => Yii::t('app', 'meta_description'), | |
110 | + 'seo_text' => Yii::t('app', 'seo_text'), | |
110 | 111 | ]; |
111 | 112 | } |
112 | 113 | |
... | ... | @@ -123,6 +124,6 @@ |
123 | 124 | */ |
124 | 125 | public function getSeoDynamic() |
125 | 126 | { |
126 | - return $this->hasOne(SeoDynamic::className(), [ 'seo_dynamic_id' => 'seo_dynamic_id' ]); | |
127 | + return $this->hasOne(SeoDynamic::className(), [ 'id' => 'seo_dynamic_id' ]); | |
127 | 128 | } |
128 | 129 | } | ... | ... |
common/models/SeoDynamicSearch.php
... | ... | @@ -27,7 +27,7 @@ |
27 | 27 | return [ |
28 | 28 | [ |
29 | 29 | [ |
30 | - 'seo_dynamic_id', | |
30 | + 'id', | |
31 | 31 | 'status', |
32 | 32 | ], |
33 | 33 | 'integer', |
... | ... | @@ -68,60 +68,74 @@ |
68 | 68 | |
69 | 69 | // add conditions that should always apply here |
70 | 70 | |
71 | - $dataProvider = new ActiveDataProvider([ | |
72 | - 'query' => $query, | |
73 | - 'sort' => [ | |
74 | - 'attributes' => [ | |
75 | - 'seo_dynamic_id', | |
76 | - 'action', | |
77 | - 'fields', | |
78 | - 'status', | |
79 | - 'param', | |
80 | - 'title' => [ | |
81 | - 'asc' => [ 'seo_dynamic_lang.title' => SORT_ASC ], | |
82 | - 'desc' => [ 'seo_dynamic_lang.title' => SORT_DESC ], | |
71 | + $dataProvider = new ActiveDataProvider( | |
72 | + [ | |
73 | + 'query' => $query, | |
74 | + 'sort' => [ | |
75 | + 'attributes' => [ | |
76 | + 'id', | |
77 | + 'action', | |
78 | + 'fields', | |
79 | + 'status', | |
80 | + 'param', | |
81 | + 'title' => [ | |
82 | + 'asc' => [ 'seo_dynamic_lang.title' => SORT_ASC ], | |
83 | + 'desc' => [ 'seo_dynamic_lang.title' => SORT_DESC ], | |
84 | + ], | |
83 | 85 | ], |
84 | 86 | ], |
85 | - ], | |
86 | - ]); | |
87 | + ] | |
88 | + ); | |
87 | 89 | |
88 | 90 | $this->load($params); |
89 | 91 | |
90 | - if(!$this->validate()) { | |
92 | + if (!$this->validate()) { | |
91 | 93 | // uncomment the following line if you do not want to return any records when validation fails |
92 | 94 | // $query->where('0=1'); |
93 | 95 | return $dataProvider; |
94 | 96 | } |
95 | 97 | |
96 | 98 | // grid filtering conditions |
97 | - $query->andWhere([ | |
98 | - 'seo_category_id' => $seo_category_id, | |
99 | - ]) | |
100 | - ->andFilterWhere([ | |
101 | - 'seo_dynamic_id' => $this->seo_dynamic_id, | |
102 | - 'status' => $this->status, | |
103 | - ]); | |
99 | + $query->andWhere( | |
100 | + [ | |
101 | + 'seo_category_id' => $seo_category_id, | |
102 | + ] | |
103 | + ) | |
104 | + ->andFilterWhere( | |
105 | + [ | |
106 | + 'id' => $this->id, | |
107 | + 'status' => $this->status, | |
108 | + ] | |
109 | + ); | |
104 | 110 | |
105 | - $query->andFilterWhere([ | |
106 | - 'ilike', | |
107 | - 'action', | |
108 | - $this->action, | |
109 | - ]) | |
110 | - ->andFilterWhere([ | |
111 | - 'ilike', | |
112 | - 'fields', | |
113 | - $this->fields, | |
114 | - ]) | |
115 | - ->andFilterWhere([ | |
116 | - 'ilike', | |
117 | - 'param', | |
118 | - $this->param, | |
119 | - ]) | |
120 | - ->andFilterWhere([ | |
121 | - 'ilike', | |
122 | - 'seo_dynamic_lang.title', | |
123 | - $this->title, | |
124 | - ]); | |
111 | + $query->andFilterWhere( | |
112 | + [ | |
113 | + 'ilike', | |
114 | + 'action', | |
115 | + $this->action, | |
116 | + ] | |
117 | + ) | |
118 | + ->andFilterWhere( | |
119 | + [ | |
120 | + 'ilike', | |
121 | + 'fields', | |
122 | + $this->fields, | |
123 | + ] | |
124 | + ) | |
125 | + ->andFilterWhere( | |
126 | + [ | |
127 | + 'ilike', | |
128 | + 'param', | |
129 | + $this->param, | |
130 | + ] | |
131 | + ) | |
132 | + ->andFilterWhere( | |
133 | + [ | |
134 | + 'ilike', | |
135 | + 'seo_dynamic_lang.title', | |
136 | + $this->title, | |
137 | + ] | |
138 | + ); | |
125 | 139 | |
126 | 140 | return $dataProvider; |
127 | 141 | } | ... | ... |
common/models/SeoLang.php
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This is the model class for table "seo_lang". |
11 | + * | |
11 | 12 | * @property integer $seo_id |
12 | 13 | * @property integer $language_id |
13 | 14 | * @property string $title |
... | ... | @@ -83,7 +84,7 @@ |
83 | 84 | 'exist', |
84 | 85 | 'skipOnError' => true, |
85 | 86 | 'targetClass' => Seo::className(), |
86 | - 'targetAttribute' => [ 'seo_id' => 'seo_id' ], | |
87 | + 'targetAttribute' => [ 'seo_id' => 'id' ], | |
87 | 88 | ], |
88 | 89 | ]; |
89 | 90 | } |
... | ... | @@ -94,13 +95,13 @@ |
94 | 95 | public function attributeLabels() |
95 | 96 | { |
96 | 97 | return [ |
97 | - 'seo_id' => Yii::t('app', 'seo_id'), | |
98 | - 'language_id' => Yii::t('app', 'language_id'), | |
99 | - 'title' => Yii::t('app', 'title'), | |
98 | + 'seo_id' => Yii::t('app', 'seo_id'), | |
99 | + 'language_id' => Yii::t('app', 'language_id'), | |
100 | + 'title' => Yii::t('app', 'title'), | |
100 | 101 | 'meta_description' => Yii::t('app', 'meta_description'), |
101 | - 'h1' => Yii::t('app', 'h1'), | |
102 | - 'meta' => Yii::t('app', 'meta'), | |
103 | - 'seo_text' => Yii::t('app', 'seo_text'), | |
102 | + 'h1' => Yii::t('app', 'h1'), | |
103 | + 'meta' => Yii::t('app', 'meta'), | |
104 | + 'seo_text' => Yii::t('app', 'seo_text'), | |
104 | 105 | ]; |
105 | 106 | } |
106 | 107 | |
... | ... | @@ -117,6 +118,6 @@ |
117 | 118 | */ |
118 | 119 | public function getSeo() |
119 | 120 | { |
120 | - return $this->hasOne(Seo::className(), [ 'seo_id' => 'seo_id' ]); | |
121 | + return $this->hasOne(Seo::className(), [ 'id' => 'seo_id' ]); | |
121 | 122 | } |
122 | 123 | } | ... | ... |
common/models/SeoSearch.php
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | { |
34 | 34 | return [ |
35 | 35 | [ |
36 | - [ 'seo_id' ], | |
36 | + [ 'id' ], | |
37 | 37 | 'integer', |
38 | 38 | ], |
39 | 39 | [ |
... | ... | @@ -73,79 +73,95 @@ |
73 | 73 | |
74 | 74 | // add conditions that should always apply here |
75 | 75 | |
76 | - $dataProvider = new ActiveDataProvider([ | |
77 | - 'query' => $query, | |
78 | - 'sort' => [ | |
79 | - 'attributes' => [ | |
80 | - 'seo_id', | |
81 | - 'url', | |
82 | - 'title' => [ | |
83 | - 'asc' => [ 'seo_lang.title' => SORT_ASC ], | |
84 | - 'desc' => [ 'seo_lang.title' => SORT_DESC ], | |
85 | - ], | |
86 | - 'meta_description' => [ | |
87 | - 'asc' => [ 'seo_lang.meta_description' => SORT_ASC ], | |
88 | - 'desc' => [ 'seo_lang.meta_description' => SORT_DESC ], | |
89 | - ], | |
90 | - 'h1' => [ | |
91 | - 'asc' => [ 'seo_lang.h1' => SORT_ASC ], | |
92 | - 'desc' => [ 'seo_lang.h1' => SORT_DESC ], | |
93 | - ], | |
94 | - 'meta' => [ | |
95 | - 'asc' => [ 'seo_lang.meta' => SORT_ASC ], | |
96 | - 'desc' => [ 'seo_lang.meta' => SORT_DESC ], | |
97 | - ], | |
98 | - 'seo_text' => [ | |
99 | - 'asc' => [ 'seo_lang.seo_text' => SORT_ASC ], | |
100 | - 'desc' => [ 'seo_lang.seo_text' => SORT_DESC ], | |
76 | + $dataProvider = new ActiveDataProvider( | |
77 | + [ | |
78 | + 'query' => $query, | |
79 | + 'sort' => [ | |
80 | + 'attributes' => [ | |
81 | + 'id', | |
82 | + 'url', | |
83 | + 'title' => [ | |
84 | + 'asc' => [ 'seo_lang.title' => SORT_ASC ], | |
85 | + 'desc' => [ 'seo_lang.title' => SORT_DESC ], | |
86 | + ], | |
87 | + 'meta_description' => [ | |
88 | + 'asc' => [ 'seo_lang.meta_description' => SORT_ASC ], | |
89 | + 'desc' => [ 'seo_lang.meta_description' => SORT_DESC ], | |
90 | + ], | |
91 | + 'h1' => [ | |
92 | + 'asc' => [ 'seo_lang.h1' => SORT_ASC ], | |
93 | + 'desc' => [ 'seo_lang.h1' => SORT_DESC ], | |
94 | + ], | |
95 | + 'meta' => [ | |
96 | + 'asc' => [ 'seo_lang.meta' => SORT_ASC ], | |
97 | + 'desc' => [ 'seo_lang.meta' => SORT_DESC ], | |
98 | + ], | |
99 | + 'seo_text' => [ | |
100 | + 'asc' => [ 'seo_lang.seo_text' => SORT_ASC ], | |
101 | + 'desc' => [ 'seo_lang.seo_text' => SORT_DESC ], | |
102 | + ], | |
101 | 103 | ], |
102 | 104 | ], |
103 | - ], | |
104 | - ]); | |
105 | + ] | |
106 | + ); | |
105 | 107 | |
106 | 108 | $this->load($params); |
107 | 109 | |
108 | - if(!$this->validate()) { | |
110 | + if (!$this->validate()) { | |
109 | 111 | // uncomment the following line if you do not want to return any records when validation fails |
110 | 112 | // $query->where('0=1'); |
111 | 113 | return $dataProvider; |
112 | 114 | } |
113 | 115 | |
114 | 116 | // grid filtering conditions |
115 | - $query->andFilterWhere([ | |
116 | - 'seo_id' => $this->seo_id, | |
117 | - ]); | |
117 | + $query->andFilterWhere( | |
118 | + [ | |
119 | + 'id' => $this->id, | |
120 | + ] | |
121 | + ); | |
118 | 122 | |
119 | - $query->andFilterWhere([ | |
120 | - 'like', | |
121 | - 'url', | |
122 | - $this->url, | |
123 | - ]) | |
124 | - ->andFilterWhere([ | |
125 | - 'ilike', | |
126 | - 'seo_lang.title', | |
127 | - $this->title, | |
128 | - ]) | |
129 | - ->andFilterWhere([ | |
130 | - 'ilike', | |
131 | - 'seo_lang.meta_description', | |
132 | - $this->meta_description, | |
133 | - ]) | |
134 | - ->andFilterWhere([ | |
135 | - 'ilike', | |
136 | - 'seo_lang.h1', | |
137 | - $this->h1, | |
138 | - ]) | |
139 | - ->andFilterWhere([ | |
140 | - 'ilike', | |
141 | - 'seo_lang.meta', | |
142 | - $this->meta, | |
143 | - ]) | |
144 | - ->andFilterWhere([ | |
145 | - 'ilike', | |
146 | - 'seo_lang.seo_text', | |
147 | - $this->seoText, | |
148 | - ]); | |
123 | + $query->andFilterWhere( | |
124 | + [ | |
125 | + 'like', | |
126 | + 'url', | |
127 | + $this->url, | |
128 | + ] | |
129 | + ) | |
130 | + ->andFilterWhere( | |
131 | + [ | |
132 | + 'ilike', | |
133 | + 'seo_lang.title', | |
134 | + $this->title, | |
135 | + ] | |
136 | + ) | |
137 | + ->andFilterWhere( | |
138 | + [ | |
139 | + 'ilike', | |
140 | + 'seo_lang.meta_description', | |
141 | + $this->meta_description, | |
142 | + ] | |
143 | + ) | |
144 | + ->andFilterWhere( | |
145 | + [ | |
146 | + 'ilike', | |
147 | + 'seo_lang.h1', | |
148 | + $this->h1, | |
149 | + ] | |
150 | + ) | |
151 | + ->andFilterWhere( | |
152 | + [ | |
153 | + 'ilike', | |
154 | + 'seo_lang.meta', | |
155 | + $this->meta, | |
156 | + ] | |
157 | + ) | |
158 | + ->andFilterWhere( | |
159 | + [ | |
160 | + 'ilike', | |
161 | + 'seo_lang.seo_text', | |
162 | + $this->seoText, | |
163 | + ] | |
164 | + ); | |
149 | 165 | |
150 | 166 | return $dataProvider; |
151 | 167 | } | ... | ... |
common/models/Service.php
... | ... | @@ -12,7 +12,8 @@ |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * This is the model class for table "service". |
15 | - * @property integer $service_id | |
15 | + * | |
16 | + * @property integer $id | |
16 | 17 | * @property string $image |
17 | 18 | * @property integer $created_at |
18 | 19 | * @property integer $updated_at |
... | ... | @@ -98,7 +99,7 @@ |
98 | 99 | public function attributeLabels() |
99 | 100 | { |
100 | 101 | return [ |
101 | - 'service_id' => Yii::t('app', 'service_id'), | |
102 | + 'id' => Yii::t('app', 'service_id'), | |
102 | 103 | 'image' => Yii::t('app', 'image'), |
103 | 104 | 'created_at' => Yii::t('app', 'created_at'), |
104 | 105 | 'updated_at' => Yii::t('app', 'updated_at'), | ... | ... |
common/models/ServiceLang.php
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This is the model class for table "service_lang". |
11 | + * | |
11 | 12 | * @property integer $service_id |
12 | 13 | * @property integer $language_id |
13 | 14 | * @property string $title |
... | ... | @@ -42,7 +43,7 @@ |
42 | 43 | { |
43 | 44 | return [ |
44 | 45 | 'slug' => [ |
45 | - 'class' => 'common\behaviors\Slug', | |
46 | + 'class' => 'common\behaviors\Slug', | |
46 | 47 | ], |
47 | 48 | ]; |
48 | 49 | } |
... | ... | @@ -101,7 +102,7 @@ |
101 | 102 | 'exist', |
102 | 103 | 'skipOnError' => true, |
103 | 104 | 'targetClass' => Service::className(), |
104 | - 'targetAttribute' => [ 'service_id' => 'service_id' ], | |
105 | + 'targetAttribute' => [ 'service_id' => 'id' ], | |
105 | 106 | ], |
106 | 107 | ]; |
107 | 108 | } |
... | ... | @@ -112,14 +113,14 @@ |
112 | 113 | public function attributeLabels() |
113 | 114 | { |
114 | 115 | return [ |
115 | - 'service_id' => Yii::t('app', 'service_id'), | |
116 | - 'language_id' => Yii::t('app', 'language_id'), | |
117 | - 'title' => Yii::t('app', 'name'), | |
118 | - 'body' => Yii::t('app', 'body'), | |
119 | - 'seo_text' => Yii::t('app', 'seo_text'), | |
120 | - 'meta_title' => Yii::t('app', 'meta_title'), | |
116 | + 'service_id' => Yii::t('app', 'service_id'), | |
117 | + 'language_id' => Yii::t('app', 'language_id'), | |
118 | + 'title' => Yii::t('app', 'name'), | |
119 | + 'body' => Yii::t('app', 'body'), | |
120 | + 'seo_text' => Yii::t('app', 'seo_text'), | |
121 | + 'meta_title' => Yii::t('app', 'meta_title'), | |
121 | 122 | 'meta_description' => Yii::t('app', 'meta_description'), |
122 | - 'h1' => Yii::t('app', 'h1'), | |
123 | + 'h1' => Yii::t('app', 'h1'), | |
123 | 124 | ]; |
124 | 125 | } |
125 | 126 | |
... | ... | @@ -136,6 +137,6 @@ |
136 | 137 | */ |
137 | 138 | public function getService() |
138 | 139 | { |
139 | - return $this->hasOne(Service::className(), [ 'service_id' => 'service_id' ]); | |
140 | + return $this->hasOne(Service::className(), [ 'id' => 'service_id' ]); | |
140 | 141 | } |
141 | 142 | } | ... | ... |
common/models/ServiceSearch.php
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | return [ |
25 | 25 | [ |
26 | 26 | [ |
27 | - 'service_id', | |
27 | + 'id', | |
28 | 28 | 'created_at', |
29 | 29 | 'updated_at', |
30 | 30 | ], |
... | ... | @@ -55,24 +55,28 @@ |
55 | 55 | |
56 | 56 | // add conditions that should always apply here |
57 | 57 | |
58 | - $dataProvider = new ActiveDataProvider([ | |
59 | - 'query' => $query, | |
60 | - ]); | |
58 | + $dataProvider = new ActiveDataProvider( | |
59 | + [ | |
60 | + 'query' => $query, | |
61 | + ] | |
62 | + ); | |
61 | 63 | |
62 | 64 | $this->load($params); |
63 | 65 | |
64 | - if(!$this->validate()) { | |
66 | + if (!$this->validate()) { | |
65 | 67 | // uncomment the following line if you do not want to return any records when validation fails |
66 | 68 | // $query->where('0=1'); |
67 | 69 | return $dataProvider; |
68 | 70 | } |
69 | 71 | |
70 | 72 | // grid filtering conditions |
71 | - $query->andFilterWhere([ | |
72 | - 'service_id' => $this->service_id, | |
73 | - 'created_at' => $this->created_at, | |
74 | - 'updated_at' => $this->updated_at, | |
75 | - ]); | |
73 | + $query->andFilterWhere( | |
74 | + [ | |
75 | + 'id' => $this->id, | |
76 | + 'created_at' => $this->created_at, | |
77 | + 'updated_at' => $this->updated_at, | |
78 | + ] | |
79 | + ); | |
76 | 80 | |
77 | 81 | return $dataProvider; |
78 | 82 | } | ... | ... |
common/models/Slider.php
... | ... | @@ -7,13 +7,14 @@ |
7 | 7 | |
8 | 8 | /** |
9 | 9 | * This is the model class for table "slider". |
10 | - * @property integer $slider_id | |
11 | - * @property integer $speed | |
12 | - * @property integer $duration | |
13 | - * @property string $title | |
14 | - * @property integer $status | |
15 | - * @property integer $width | |
16 | - * @property integer $height | |
10 | + * | |
11 | + * @property integer $id | |
12 | + * @property integer $speed | |
13 | + * @property integer $duration | |
14 | + * @property string $title | |
15 | + * @property integer $status | |
16 | + * @property integer $width | |
17 | + * @property integer $height | |
17 | 18 | * @property SliderImage[] $sliderImage |
18 | 19 | */ |
19 | 20 | class Slider extends ActiveRecord |
... | ... | @@ -60,9 +61,13 @@ |
60 | 61 | 'title', |
61 | 62 | 'unique', |
62 | 63 | 'targetClass' => '\common\models\Slider', |
63 | - 'message' => Yii::t('app', 'message', [ | |
64 | - 'field' => 'Title', | |
65 | - ]), | |
64 | + 'message' => Yii::t( | |
65 | + 'app', | |
66 | + 'message', | |
67 | + [ | |
68 | + 'field' => 'Title', | |
69 | + ] | |
70 | + ), | |
66 | 71 | ], |
67 | 72 | ]; |
68 | 73 | } |
... | ... | @@ -73,13 +78,13 @@ |
73 | 78 | public function attributeLabels() |
74 | 79 | { |
75 | 80 | return [ |
76 | - 'slider_id' => Yii::t('app', 'slider_id'), | |
77 | - 'speed' => Yii::t('app', 'speed'), | |
78 | - 'duration' => Yii::t('app', 'duration'), | |
79 | - 'title' => Yii::t('app', 'title'), | |
80 | - 'status' => Yii::t('app', 'status'), | |
81 | - 'width' => Yii::t('app', 'width'), | |
82 | - 'height' => Yii::t('app', 'height'), | |
81 | + 'id' => Yii::t('app', 'slider_id'), | |
82 | + 'speed' => Yii::t('app', 'speed'), | |
83 | + 'duration' => Yii::t('app', 'duration'), | |
84 | + 'title' => Yii::t('app', 'title'), | |
85 | + 'status' => Yii::t('app', 'status'), | |
86 | + 'width' => Yii::t('app', 'width'), | |
87 | + 'height' => Yii::t('app', 'height'), | |
83 | 88 | ]; |
84 | 89 | } |
85 | 90 | |
... | ... | @@ -88,7 +93,7 @@ |
88 | 93 | */ |
89 | 94 | public function getSliderImage() |
90 | 95 | { |
91 | - return $this->hasMany(SliderImage::className(), [ 'slider_id' => 'slider_id' ]) | |
96 | + return $this->hasMany(SliderImage::className(), [ 'slider_id' => 'id' ]) | |
92 | 97 | ->where([ SliderImage::tableName() . '.status' => 1 ]); |
93 | 98 | } |
94 | 99 | ... | ... |
common/models/SliderImage.php
... | ... | @@ -11,7 +11,8 @@ |
11 | 11 | |
12 | 12 | /** |
13 | 13 | * This is the model class for table "slider_image". |
14 | - * @property integer $slider_image_id | |
14 | + * | |
15 | + * @property integer $id | |
15 | 16 | * @property integer $slider_id |
16 | 17 | * @property string $image |
17 | 18 | * @property string $url |
... | ... | @@ -82,7 +83,7 @@ |
82 | 83 | 'exist', |
83 | 84 | 'skipOnError' => true, |
84 | 85 | 'targetClass' => Slider::className(), |
85 | - 'targetAttribute' => [ 'slider_id' => 'slider_id' ], | |
86 | + 'targetAttribute' => [ 'slider_id' => 'id' ], | |
86 | 87 | ], |
87 | 88 | ]; |
88 | 89 | } |
... | ... | @@ -111,12 +112,12 @@ |
111 | 112 | public function attributeLabels() |
112 | 113 | { |
113 | 114 | return [ |
114 | - 'slider_image_id' => Yii::t('app', 'slider_image_id'), | |
115 | - 'slider_id' => Yii::t('app', 'slider_id'), | |
116 | - 'image' => Yii::t('app', 'image'), | |
117 | - 'url' => Yii::t('app', 'url'), | |
118 | - 'status' => Yii::t('app', 'status'), | |
119 | - 'sort' => Yii::t('app', 'sort'), | |
115 | + 'id' => Yii::t('app', 'slider_image_id'), | |
116 | + 'slider_id' => Yii::t('app', 'slider_id'), | |
117 | + 'image' => Yii::t('app', 'image'), | |
118 | + 'url' => Yii::t('app', 'url'), | |
119 | + 'status' => Yii::t('app', 'status'), | |
120 | + 'sort' => Yii::t('app', 'sort'), | |
120 | 121 | ]; |
121 | 122 | } |
122 | 123 | |
... | ... | @@ -125,7 +126,7 @@ |
125 | 126 | */ |
126 | 127 | public function getSlider() |
127 | 128 | { |
128 | - return $this->hasOne(Slider::className(), [ 'slider_id' => 'slider_id' ]); | |
129 | + return $this->hasOne(Slider::className(), [ 'id' => 'slider_id' ]); | |
129 | 130 | } |
130 | 131 | |
131 | 132 | } | ... | ... |
common/models/SliderImageLang.php
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This is the model class for table "slider_image_lang". |
11 | + * | |
11 | 12 | * @property integer $slider_image_id |
12 | 13 | * @property integer $language_id |
13 | 14 | * @property string $title |
... | ... | @@ -72,7 +73,7 @@ |
72 | 73 | 'exist', |
73 | 74 | 'skipOnError' => true, |
74 | 75 | 'targetClass' => SliderImage::className(), |
75 | - 'targetAttribute' => [ 'slider_image_id' => 'slider_image_id' ], | |
76 | + 'targetAttribute' => [ 'slider_image_id' => 'id' ], | |
76 | 77 | ], |
77 | 78 | ]; |
78 | 79 | } |
... | ... | @@ -103,6 +104,6 @@ |
103 | 104 | */ |
104 | 105 | public function getSliderImage() |
105 | 106 | { |
106 | - return $this->hasOne(SliderImage::className(), [ 'slider_image_id' => 'slider_image_id' ]); | |
107 | + return $this->hasOne(SliderImage::className(), [ 'id' => 'slider_image_id' ]); | |
107 | 108 | } |
108 | 109 | } | ... | ... |
common/models/SliderImageSearch.php
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 | return [ |
26 | 26 | [ |
27 | 27 | [ |
28 | - 'slider_image_id', | |
28 | + 'id', | |
29 | 29 | 'slider_id', |
30 | 30 | 'status', |
31 | 31 | 'sort', |
... | ... | @@ -64,31 +64,37 @@ |
64 | 64 | |
65 | 65 | // add conditions that should always apply here |
66 | 66 | |
67 | - $dataProvider = new ActiveDataProvider([ | |
68 | - 'query' => $query, | |
69 | - ]); | |
67 | + $dataProvider = new ActiveDataProvider( | |
68 | + [ | |
69 | + 'query' => $query, | |
70 | + ] | |
71 | + ); | |
70 | 72 | |
71 | 73 | $this->load($params); |
72 | 74 | |
73 | - if(!$this->validate()) { | |
75 | + if (!$this->validate()) { | |
74 | 76 | // uncomment the following line if you do not want to return any records when validation fails |
75 | 77 | // $query->where('0=1'); |
76 | 78 | return $dataProvider; |
77 | 79 | } |
78 | 80 | |
79 | 81 | // grid filtering conditions |
80 | - $query->andFilterWhere([ | |
81 | - 'slider_image_id' => $this->slider_image_id, | |
82 | - 'slider_id' => $slider_id, | |
83 | - 'status' => $this->status, | |
84 | - 'sort' => $this->sort, | |
85 | - ]); | |
82 | + $query->andFilterWhere( | |
83 | + [ | |
84 | + 'id' => $this->id, | |
85 | + 'slider_id' => $slider_id, | |
86 | + 'status' => $this->status, | |
87 | + 'sort' => $this->sort, | |
88 | + ] | |
89 | + ); | |
86 | 90 | |
87 | - $query->andFilterWhere([ | |
88 | - 'like', | |
89 | - 'url', | |
90 | - $this->url, | |
91 | - ]); | |
91 | + $query->andFilterWhere( | |
92 | + [ | |
93 | + 'like', | |
94 | + 'url', | |
95 | + $this->url, | |
96 | + ] | |
97 | + ); | |
92 | 98 | |
93 | 99 | return $dataProvider; |
94 | 100 | } | ... | ... |
common/models/SliderSearch.php
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | return [ |
22 | 22 | [ |
23 | 23 | [ |
24 | - 'slider_id', | |
24 | + 'id', | |
25 | 25 | 'status', |
26 | 26 | ], |
27 | 27 | 'integer', |
... | ... | @@ -55,29 +55,35 @@ |
55 | 55 | |
56 | 56 | // add conditions that should always apply here |
57 | 57 | |
58 | - $dataProvider = new ActiveDataProvider([ | |
59 | - 'query' => $query, | |
60 | - ]); | |
58 | + $dataProvider = new ActiveDataProvider( | |
59 | + [ | |
60 | + 'query' => $query, | |
61 | + ] | |
62 | + ); | |
61 | 63 | |
62 | 64 | $this->load($params); |
63 | 65 | |
64 | - if(!$this->validate()) { | |
66 | + if (!$this->validate()) { | |
65 | 67 | // uncomment the following line if you do not want to return any records when validation fails |
66 | 68 | // $query->where('0=1'); |
67 | 69 | return $dataProvider; |
68 | 70 | } |
69 | 71 | |
70 | 72 | // grid filtering conditions |
71 | - $query->andFilterWhere([ | |
72 | - 'slider_id' => $this->slider_id, | |
73 | - 'status' => $this->status, | |
74 | - ]); | |
73 | + $query->andFilterWhere( | |
74 | + [ | |
75 | + 'id' => $this->id, | |
76 | + 'status' => $this->status, | |
77 | + ] | |
78 | + ); | |
75 | 79 | |
76 | - $query->andFilterWhere([ | |
77 | - 'like', | |
78 | - 'title', | |
79 | - $this->title, | |
80 | - ]); | |
80 | + $query->andFilterWhere( | |
81 | + [ | |
82 | + 'like', | |
83 | + 'title', | |
84 | + $this->title, | |
85 | + ] | |
86 | + ); | |
81 | 87 | |
82 | 88 | return $dataProvider; |
83 | 89 | } | ... | ... |
common/modules/product/controllers/ManageController.php
... | ... | @@ -39,6 +39,7 @@ |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Lists all Product models. |
42 | + * | |
42 | 43 | * @return mixed |
43 | 44 | */ |
44 | 45 | public function actionIndex() |
... | ... | @@ -46,10 +47,13 @@ |
46 | 47 | $searchModel = new ProductSearch(); |
47 | 48 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); |
48 | 49 | |
49 | - return $this->render('index', [ | |
50 | - 'searchModel' => $searchModel, | |
51 | - 'dataProvider' => $dataProvider, | |
52 | - ]); | |
50 | + return $this->render( | |
51 | + 'index', | |
52 | + [ | |
53 | + 'searchModel' => $searchModel, | |
54 | + 'dataProvider' => $dataProvider, | |
55 | + ] | |
56 | + ); | |
53 | 57 | } |
54 | 58 | |
55 | 59 | /** |
... | ... | @@ -69,17 +73,21 @@ |
69 | 73 | ->with('lang') |
70 | 74 | ->all(); |
71 | 75 | $properties = $model->getProperties(); |
72 | - return $this->render('view', [ | |
73 | - 'model' => $this->findModel($id), | |
74 | - 'categories' => $categories, | |
75 | - 'variants' => $variants, | |
76 | - 'properties' => $properties, | |
77 | - ]); | |
76 | + return $this->render( | |
77 | + 'view', | |
78 | + [ | |
79 | + 'model' => $this->findModel($id), | |
80 | + 'categories' => $categories, | |
81 | + 'variants' => $variants, | |
82 | + 'properties' => $properties, | |
83 | + ] | |
84 | + ); | |
78 | 85 | } |
79 | 86 | |
80 | 87 | /** |
81 | 88 | * Creates a new Product model. |
82 | 89 | * If creation is successful, the browser will be redirected to the 'view' page. |
90 | + * | |
83 | 91 | * @return mixed |
84 | 92 | */ |
85 | 93 | public function actionCreate() |
... | ... | @@ -87,19 +95,24 @@ |
87 | 95 | $model = new Product(); |
88 | 96 | $model->detachBehavior('techSpec'); |
89 | 97 | $model->generateLangs(); |
90 | - if($model->load(Yii::$app->request->post())) { | |
98 | + if ($model->load(Yii::$app->request->post())) { | |
91 | 99 | $model->loadLangs(\Yii::$app->request); |
92 | - if($model->save() && $model->transactionStatus) { | |
93 | - return $this->redirect([ | |
94 | - 'view', | |
95 | - 'id' => $model->id, | |
96 | - ]); | |
100 | + if ($model->save() && $model->transactionStatus) { | |
101 | + return $this->redirect( | |
102 | + [ | |
103 | + 'view', | |
104 | + 'id' => $model->id, | |
105 | + ] | |
106 | + ); | |
97 | 107 | } |
98 | 108 | } |
99 | - return $this->render('create', [ | |
100 | - 'model' => $model, | |
101 | - 'modelLangs' => $model->modelLangs, | |
102 | - ]); | |
109 | + return $this->render( | |
110 | + 'create', | |
111 | + [ | |
112 | + 'model' => $model, | |
113 | + 'modelLangs' => $model->modelLangs, | |
114 | + ] | |
115 | + ); | |
103 | 116 | } |
104 | 117 | |
105 | 118 | /** |
... | ... | @@ -114,24 +127,29 @@ |
114 | 127 | { |
115 | 128 | $model = $this->findModel($id); |
116 | 129 | $model->generateLangs(); |
117 | - if($model->load(Yii::$app->request->post())) { | |
130 | + if ($model->load(Yii::$app->request->post())) { | |
118 | 131 | $model->loadLangs(\Yii::$app->request); |
119 | - if($model->save() && $model->transactionStatus) { | |
120 | - return $this->redirect([ | |
121 | - 'view', | |
122 | - 'id' => $model->id, | |
123 | - ]); | |
132 | + if ($model->save() && $model->transactionStatus) { | |
133 | + return $this->redirect( | |
134 | + [ | |
135 | + 'view', | |
136 | + 'id' => $model->id, | |
137 | + ] | |
138 | + ); | |
124 | 139 | } |
125 | 140 | } |
126 | 141 | /** |
127 | 142 | * @var ActiveQuery $groups |
128 | 143 | */ |
129 | 144 | $groups = $model->getTaxGroupsByLevel(0); |
130 | - return $this->render('update', [ | |
131 | - 'model' => $model, | |
132 | - 'modelLangs' => $model->modelLangs, | |
133 | - 'groups' => $groups, | |
134 | - ]); | |
145 | + return $this->render( | |
146 | + 'update', | |
147 | + [ | |
148 | + 'model' => $model, | |
149 | + 'modelLangs' => $model->modelLangs, | |
150 | + 'groups' => $groups, | |
151 | + ] | |
152 | + ); | |
135 | 153 | } |
136 | 154 | |
137 | 155 | /** |
... | ... | @@ -153,7 +171,7 @@ |
153 | 171 | { |
154 | 172 | $image = ProductImage::findOne($id); |
155 | 173 | |
156 | - if($image) { | |
174 | + if ($image) { | |
157 | 175 | $image->delete(); |
158 | 176 | } |
159 | 177 | |
... | ... | @@ -183,13 +201,13 @@ |
183 | 201 | return $this->redirect([ 'index' ]); |
184 | 202 | } |
185 | 203 | |
186 | - public function actionAkciya($id) | |
204 | + public function actionIsDiscount($id) | |
187 | 205 | { |
188 | 206 | $model = $this->findModel($id); |
189 | 207 | |
190 | - $model->akciya = intval(empty( $model->akciya )); | |
208 | + $model->is_discount = intval(empty( $model->is_discount )); | |
191 | 209 | |
192 | - $model->save(false, [ 'akciya' ]); | |
210 | + $model->save(false, [ 'is_discount' ]); | |
193 | 211 | |
194 | 212 | return $this->redirect([ 'index' ]); |
195 | 213 | } |
... | ... | @@ -199,43 +217,51 @@ |
199 | 217 | $model = new Import(); |
200 | 218 | |
201 | 219 | $languages = Language::find() |
202 | - ->select([ | |
203 | - 'name', | |
204 | - 'id', | |
205 | - ]) | |
220 | + ->select( | |
221 | + [ | |
222 | + 'name', | |
223 | + 'id', | |
224 | + ] | |
225 | + ) | |
206 | 226 | ->where([ 'status' => 1 ]) |
207 | 227 | ->orderBy([ 'default' => SORT_DESC ]) |
208 | 228 | ->asArray() |
209 | 229 | ->indexBy('id') |
210 | 230 | ->column(); |
211 | 231 | |
212 | - if($model->load(Yii::$app->request->post())) { | |
232 | + if ($model->load(Yii::$app->request->post())) { | |
213 | 233 | \Yii::$app->session->set('export_lang', $model->lang); |
214 | 234 | $file = UploadedFile::getInstances($model, 'file'); |
215 | 235 | $method = 'go' . ucfirst($model->type); |
216 | 236 | $target = Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFile' . ucfirst($model->type)); |
217 | - if(empty( $file )) { | |
237 | + if (empty( $file )) { | |
218 | 238 | $model->errors[] = 'File not upload'; |
219 | - } elseif($method == 'goPrices' && $file[ 0 ]->name != 'file_1.csv') { | |
239 | + } elseif ($method == 'goPrices' && $file[ 0 ]->name != 'file_1.csv') { | |
220 | 240 | $model->errors[] = 'File need "file_1.csv"'; |
221 | - } elseif($method == 'goProducts' && $file[ 0 ]->name == 'file_1.csv') { | |
241 | + } elseif ($method == 'goProducts' && $file[ 0 ]->name == 'file_1.csv') { | |
222 | 242 | $model->errors[] = 'File can not "file_1.csv"'; |
223 | - } elseif($model->validate() && $file[ 0 ]->saveAs($target)) { | |
243 | + } elseif ($model->validate() && $file[ 0 ]->saveAs($target)) { | |
224 | 244 | // PROCESS PAGE |
225 | - return $this->render('import-process', [ | |
226 | - 'model' => $model, | |
227 | - 'method' => $model->type, | |
228 | - 'target' => $target, | |
229 | - ]); | |
245 | + return $this->render( | |
246 | + 'import-process', | |
247 | + [ | |
248 | + 'model' => $model, | |
249 | + 'method' => $model->type, | |
250 | + 'target' => $target, | |
251 | + ] | |
252 | + ); | |
230 | 253 | } else { |
231 | 254 | $model->errors[] = 'File can not be upload or other error'; |
232 | 255 | } |
233 | 256 | } |
234 | 257 | |
235 | - return $this->render('import', [ | |
236 | - 'model' => $model, | |
237 | - 'languages' => $languages, | |
238 | - ]); | |
258 | + return $this->render( | |
259 | + 'import', | |
260 | + [ | |
261 | + 'model' => $model, | |
262 | + 'languages' => $languages, | |
263 | + ] | |
264 | + ); | |
239 | 265 | } |
240 | 266 | |
241 | 267 | public function actionProducts() |
... | ... | @@ -244,7 +270,7 @@ |
244 | 270 | |
245 | 271 | $model = new Import(); |
246 | 272 | |
247 | - if(Yii::$app->request->isAjax) { | |
273 | + if (Yii::$app->request->isAjax) { | |
248 | 274 | Yii::$app->response->format = Response::FORMAT_JSON; |
249 | 275 | return $model->goProducts($from, 1); |
250 | 276 | } else { |
... | ... | @@ -258,7 +284,7 @@ |
258 | 284 | |
259 | 285 | $model = new Import(); |
260 | 286 | |
261 | - if(Yii::$app->request->isAjax) { | |
287 | + if (Yii::$app->request->isAjax) { | |
262 | 288 | Yii::$app->response->format = Response::FORMAT_JSON; |
263 | 289 | return $model->goPrices($from, 10); |
264 | 290 | } else { |
... | ... | @@ -270,7 +296,7 @@ |
270 | 296 | { |
271 | 297 | |
272 | 298 | $model = new Export(); |
273 | - if(Yii::$app->request->isAjax) { | |
299 | + if (Yii::$app->request->isAjax) { | |
274 | 300 | Yii::$app->response->format = Response::FORMAT_JSON; |
275 | 301 | return $model->process($filename, $from); |
276 | 302 | } else { |
... | ... | @@ -282,17 +308,23 @@ |
282 | 308 | { |
283 | 309 | $model = new Export(); |
284 | 310 | |
285 | - if($model->load(Yii::$app->request->post())) { | |
311 | + if ($model->load(Yii::$app->request->post())) { | |
286 | 312 | \Yii::$app->session->set('export_lang', $model->lang); |
287 | - return $this->render('export-process', [ | |
288 | - 'model' => $model, | |
289 | - 'method' => 'export', | |
290 | - ]); | |
313 | + return $this->render( | |
314 | + 'export-process', | |
315 | + [ | |
316 | + 'model' => $model, | |
317 | + 'method' => 'export', | |
318 | + ] | |
319 | + ); | |
291 | 320 | } |
292 | 321 | |
293 | - return $this->render('export', [ | |
294 | - 'model' => $model, | |
295 | - ]); | |
322 | + return $this->render( | |
323 | + 'export', | |
324 | + [ | |
325 | + 'model' => $model, | |
326 | + ] | |
327 | + ); | |
296 | 328 | } |
297 | 329 | |
298 | 330 | /** |
... | ... | @@ -306,10 +338,10 @@ |
306 | 338 | */ |
307 | 339 | protected function findModel($id) |
308 | 340 | { |
309 | - if(( $model = Product::find() | |
310 | - ->where([ 'id' => $id ]) | |
311 | - ->with('lang') | |
312 | - ->one() ) !== NULL | |
341 | + if (( $model = Product::find() | |
342 | + ->where([ 'id' => $id ]) | |
343 | + ->with('lang') | |
344 | + ->one() ) !== null | |
313 | 345 | ) { |
314 | 346 | return $model; |
315 | 347 | } else { | ... | ... |
common/modules/product/controllers/ProductUnitController.php
... | ... | @@ -32,6 +32,7 @@ |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Lists all ProductUnit models. |
35 | + * | |
35 | 36 | * @return mixed |
36 | 37 | */ |
37 | 38 | public function actionIndex() |
... | ... | @@ -39,10 +40,13 @@ |
39 | 40 | $searchModel = new ProductUnitSearch(); |
40 | 41 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); |
41 | 42 | |
42 | - return $this->render('index', [ | |
43 | - 'searchModel' => $searchModel, | |
44 | - 'dataProvider' => $dataProvider, | |
45 | - ]); | |
43 | + return $this->render( | |
44 | + 'index', | |
45 | + [ | |
46 | + 'searchModel' => $searchModel, | |
47 | + 'dataProvider' => $dataProvider, | |
48 | + ] | |
49 | + ); | |
46 | 50 | } |
47 | 51 | |
48 | 52 | /** |
... | ... | @@ -54,33 +58,42 @@ |
54 | 58 | */ |
55 | 59 | public function actionView($id) |
56 | 60 | { |
57 | - return $this->render('view', [ | |
58 | - 'model' => $this->findModel($id), | |
59 | - ]); | |
61 | + return $this->render( | |
62 | + 'view', | |
63 | + [ | |
64 | + 'model' => $this->findModel($id), | |
65 | + ] | |
66 | + ); | |
60 | 67 | } |
61 | 68 | |
62 | 69 | /** |
63 | 70 | * Creates a new ProductUnit model. |
64 | 71 | * If creation is successful, the browser will be redirected to the 'view' page. |
72 | + * | |
65 | 73 | * @return mixed |
66 | 74 | */ |
67 | 75 | public function actionCreate() |
68 | 76 | { |
69 | 77 | $model = new ProductUnit(); |
70 | 78 | $model->generateLangs(); |
71 | - if($model->load(Yii::$app->request->post())) { | |
79 | + if ($model->load(Yii::$app->request->post())) { | |
72 | 80 | $model->loadLangs(\Yii::$app->request); |
73 | - if($model->save() && $model->transactionStatus) { | |
74 | - return $this->redirect([ | |
75 | - 'view', | |
76 | - 'id' => $model->product_unit_id, | |
77 | - ]); | |
81 | + if ($model->save() && $model->transactionStatus) { | |
82 | + return $this->redirect( | |
83 | + [ | |
84 | + 'view', | |
85 | + 'id' => $model->id, | |
86 | + ] | |
87 | + ); | |
78 | 88 | } |
79 | 89 | } |
80 | - return $this->render('create', [ | |
81 | - 'model' => $model, | |
82 | - 'modelLangs' => $model->modelLangs, | |
83 | - ]); | |
90 | + return $this->render( | |
91 | + 'create', | |
92 | + [ | |
93 | + 'model' => $model, | |
94 | + 'modelLangs' => $model->modelLangs, | |
95 | + ] | |
96 | + ); | |
84 | 97 | } |
85 | 98 | |
86 | 99 | /** |
... | ... | @@ -95,19 +108,24 @@ |
95 | 108 | { |
96 | 109 | $model = $this->findModel($id); |
97 | 110 | $model->generateLangs(); |
98 | - if($model->load(Yii::$app->request->post())) { | |
111 | + if ($model->load(Yii::$app->request->post())) { | |
99 | 112 | $model->loadLangs(\Yii::$app->request); |
100 | - if($model->save() && $model->transactionStatus) { | |
101 | - return $this->redirect([ | |
102 | - 'view', | |
103 | - 'id' => $model->product_unit_id, | |
104 | - ]); | |
113 | + if ($model->save() && $model->transactionStatus) { | |
114 | + return $this->redirect( | |
115 | + [ | |
116 | + 'view', | |
117 | + 'id' => $model->id, | |
118 | + ] | |
119 | + ); | |
105 | 120 | } |
106 | 121 | } |
107 | - return $this->render('update', [ | |
108 | - 'model' => $model, | |
109 | - 'modelLangs' => $model->modelLangs, | |
110 | - ]); | |
122 | + return $this->render( | |
123 | + 'update', | |
124 | + [ | |
125 | + 'model' => $model, | |
126 | + 'modelLangs' => $model->modelLangs, | |
127 | + ] | |
128 | + ); | |
111 | 129 | } |
112 | 130 | |
113 | 131 | /** |
... | ... | @@ -137,10 +155,10 @@ |
137 | 155 | */ |
138 | 156 | protected function findModel($id) |
139 | 157 | { |
140 | - if(( $model = ProductUnit::find() | |
141 | - ->where([ 'product_unit_id' => $id ]) | |
142 | - ->with('lang') | |
143 | - ->one() ) !== NULL | |
158 | + if (( $model = ProductUnit::find() | |
159 | + ->where([ 'id' => $id ]) | |
160 | + ->with('lang') | |
161 | + ->one() ) !== null | |
144 | 162 | ) { |
145 | 163 | return $model; |
146 | 164 | } else { | ... | ... |
common/modules/product/controllers/VariantController.php
... | ... | @@ -54,11 +54,14 @@ |
54 | 54 | $query->with('image') |
55 | 55 | ->andWhere([ 'product_id' => $product->id ]); |
56 | 56 | |
57 | - return $this->render('index', [ | |
58 | - 'searchModel' => $searchModel, | |
59 | - 'dataProvider' => $dataProvider, | |
60 | - 'product' => $product, | |
61 | - ]); | |
57 | + return $this->render( | |
58 | + 'index', | |
59 | + [ | |
60 | + 'searchModel' => $searchModel, | |
61 | + 'dataProvider' => $dataProvider, | |
62 | + 'product' => $product, | |
63 | + ] | |
64 | + ); | |
62 | 65 | } |
63 | 66 | |
64 | 67 | /** |
... | ... | @@ -72,10 +75,13 @@ |
72 | 75 | { |
73 | 76 | $model = $this->findModel($id); |
74 | 77 | $properties = $model->getProperties(); |
75 | - return $this->render('view', [ | |
76 | - 'model' => $model, | |
77 | - 'properties' => $properties, | |
78 | - ]); | |
78 | + return $this->render( | |
79 | + 'view', | |
80 | + [ | |
81 | + 'model' => $model, | |
82 | + 'properties' => $properties, | |
83 | + ] | |
84 | + ); | |
79 | 85 | } |
80 | 86 | |
81 | 87 | /** |
... | ... | @@ -92,17 +98,17 @@ |
92 | 98 | $model = new ProductVariant(); |
93 | 99 | $model->product_id = $product->id; |
94 | 100 | $model->generateLangs(); |
95 | - if($model->load(Yii::$app->request->post())) { | |
101 | + if ($model->load(Yii::$app->request->post())) { | |
96 | 102 | $model->loadLangs(\Yii::$app->request); |
97 | - if($model->save() && $model->transactionStatus) { | |
103 | + if ($model->save() && $model->transactionStatus) { | |
98 | 104 | $ProductStocks = Yii::$app->request->post('ProductStock'); |
99 | 105 | $total_quantity = 0; |
100 | - if(!empty( $ProductStocks ) && is_array($ProductStocks)) { | |
106 | + if (!empty( $ProductStocks ) && is_array($ProductStocks)) { | |
101 | 107 | $model->unlinkAll('stocks', true); |
102 | 108 | $sorted_array = []; |
103 | - foreach($ProductStocks as $subArray) { | |
104 | - if(!empty( $subArray[ 'title' ] ) && !empty( $subArray[ 'quantity' ] )) { | |
105 | - if(!empty( $sorted_array[ $subArray[ 'title' ] ] )) { | |
109 | + foreach ($ProductStocks as $subArray) { | |
110 | + if (!empty( $subArray[ 'title' ] ) && !empty( $subArray[ 'quantity' ] )) { | |
111 | + if (!empty( $sorted_array[ $subArray[ 'title' ] ] )) { | |
106 | 112 | $sorted_array[ $subArray[ 'title' ] ] += $subArray[ 'quantity' ]; |
107 | 113 | } else { |
108 | 114 | $sorted_array[ $subArray[ 'title' ] ] = $subArray[ 'quantity' ]; |
... | ... | @@ -115,25 +121,28 @@ |
115 | 121 | ->where([ 'title' => $stock_names ]) |
116 | 122 | ->indexBy('title') |
117 | 123 | ->all(); |
118 | - foreach($ProductStocks as $name => $quantity) { | |
124 | + foreach ($ProductStocks as $name => $quantity) { | |
119 | 125 | $quantity = (int) $quantity; |
120 | - if(!array_key_exists($name, $stocks)) { | |
121 | - $stock = new Stock([ | |
122 | - 'title' => $name, | |
123 | - ]); | |
124 | - if(!$stock->save()) { | |
126 | + if (!array_key_exists($name, $stocks)) { | |
127 | + $stock = new Stock( | |
128 | + [ | |
129 | + 'title' => $name, | |
130 | + ] | |
131 | + ); | |
132 | + if (!$stock->save()) { | |
125 | 133 | continue; |
126 | 134 | } |
127 | 135 | } else { |
128 | 136 | $stock = $stocks[ $name ]; |
129 | 137 | } |
130 | - $psModel = new ProductStock([ | |
131 | - 'product_id' => $model->product_id, | |
132 | - 'product_variant_id' => $model->product_variant_id, | |
133 | - 'stock_id' => $stock->stock_id, | |
134 | - 'quantity' => $quantity, | |
135 | - ]); | |
136 | - if($psModel->save()) { | |
138 | + $psModel = new ProductStock( | |
139 | + [ | |
140 | + 'product_variant_id' => $model->id, | |
141 | + 'stock_id' => $stock->id, | |
142 | + 'quantity' => $quantity, | |
143 | + ] | |
144 | + ); | |
145 | + if ($psModel->save()) { | |
137 | 146 | $total_quantity += $quantity; |
138 | 147 | } |
139 | 148 | } |
... | ... | @@ -142,22 +151,27 @@ |
142 | 151 | } |
143 | 152 | |
144 | 153 | $model->stock = $total_quantity; |
145 | - if($model->save() && $model->transactionStatus) { | |
146 | - return $this->redirect([ | |
147 | - 'index', | |
148 | - 'product_id' => $product->id, | |
149 | - ]); | |
154 | + if ($model->save() && $model->transactionStatus) { | |
155 | + return $this->redirect( | |
156 | + [ | |
157 | + 'index', | |
158 | + 'product_id' => $product->id, | |
159 | + ] | |
160 | + ); | |
150 | 161 | } |
151 | 162 | } |
152 | 163 | } |
153 | 164 | $groups = $model->getTaxGroupsByLevel(1); |
154 | - return $this->render('create', [ | |
155 | - 'model' => $model, | |
156 | - 'modelLangs' => $model->modelLangs, | |
157 | - 'groups' => $groups, | |
158 | - 'stocks' => [ new ProductStock() ], | |
159 | - 'product' => $product, | |
160 | - ]); | |
165 | + return $this->render( | |
166 | + 'create', | |
167 | + [ | |
168 | + 'model' => $model, | |
169 | + 'modelLangs' => $model->modelLangs, | |
170 | + 'groups' => $groups, | |
171 | + 'stocks' => [ new ProductStock() ], | |
172 | + 'product' => $product, | |
173 | + ] | |
174 | + ); | |
161 | 175 | } |
162 | 176 | |
163 | 177 | /** |
... | ... | @@ -174,17 +188,17 @@ |
174 | 188 | $product = $this->findProduct($product_id); |
175 | 189 | $model = $this->findModel($id); |
176 | 190 | $model->generateLangs(); |
177 | - if($model->load(Yii::$app->request->post())) { | |
191 | + if ($model->load(Yii::$app->request->post())) { | |
178 | 192 | $model->loadLangs(\Yii::$app->request); |
179 | - if($model->save() && $model->transactionStatus) { | |
193 | + if ($model->save() && $model->transactionStatus) { | |
180 | 194 | $ProductStocks = Yii::$app->request->post('ProductStock'); |
181 | 195 | $total_quantity = 0; |
182 | - if(!empty( $ProductStocks ) && is_array($ProductStocks)) { | |
196 | + if (!empty( $ProductStocks ) && is_array($ProductStocks)) { | |
183 | 197 | $model->unlinkAll('stocks', true); |
184 | 198 | $sorted_array = []; |
185 | - foreach($ProductStocks as $subArray) { | |
186 | - if(!empty( $subArray[ 'title' ] ) && !empty( $subArray[ 'quantity' ] )) { | |
187 | - if(!empty( $sorted_array[ $subArray[ 'title' ] ] )) { | |
199 | + foreach ($ProductStocks as $subArray) { | |
200 | + if (!empty( $subArray[ 'title' ] ) && !empty( $subArray[ 'quantity' ] )) { | |
201 | + if (!empty( $sorted_array[ $subArray[ 'title' ] ] )) { | |
188 | 202 | $sorted_array[ $subArray[ 'title' ] ] += $subArray[ 'quantity' ]; |
189 | 203 | } else { |
190 | 204 | $sorted_array[ $subArray[ 'title' ] ] = $subArray[ 'quantity' ]; |
... | ... | @@ -197,25 +211,28 @@ |
197 | 211 | ->where([ 'title' => $stock_names ]) |
198 | 212 | ->indexBy('title') |
199 | 213 | ->all(); |
200 | - foreach($ProductStocks as $name => $quantity) { | |
214 | + foreach ($ProductStocks as $name => $quantity) { | |
201 | 215 | $quantity = (int) $quantity; |
202 | - if(!array_key_exists($name, $stocks)) { | |
203 | - $stock = new Stock([ | |
204 | - 'title' => $name, | |
205 | - ]); | |
206 | - if(!$stock->save()) { | |
216 | + if (!array_key_exists($name, $stocks)) { | |
217 | + $stock = new Stock( | |
218 | + [ | |
219 | + 'title' => $name, | |
220 | + ] | |
221 | + ); | |
222 | + if (!$stock->save()) { | |
207 | 223 | continue; |
208 | 224 | } |
209 | 225 | } else { |
210 | 226 | $stock = $stocks[ $name ]; |
211 | 227 | } |
212 | - $psModel = new ProductStock([ | |
213 | - 'product_id' => $model->product_id, | |
214 | - 'product_variant_id' => $model->product_variant_id, | |
215 | - 'stock_id' => $stock->stock_id, | |
216 | - 'quantity' => $quantity, | |
217 | - ]); | |
218 | - if($psModel->save()) { | |
228 | + $psModel = new ProductStock( | |
229 | + [ | |
230 | + 'product_variant_id' => $model->id, | |
231 | + 'stock_id' => $stock->id, | |
232 | + 'quantity' => $quantity, | |
233 | + ] | |
234 | + ); | |
235 | + if ($psModel->save()) { | |
219 | 236 | $total_quantity += $quantity; |
220 | 237 | } |
221 | 238 | } |
... | ... | @@ -223,22 +240,27 @@ |
223 | 240 | $model->unlinkAll('stocks', true); |
224 | 241 | } |
225 | 242 | $model->stock = $total_quantity; |
226 | - if($model->save() && $model->transactionStatus) { | |
227 | - return $this->redirect([ | |
228 | - 'index', | |
229 | - 'product_id' => $product_id, | |
230 | - ]); | |
243 | + if ($model->save() && $model->transactionStatus) { | |
244 | + return $this->redirect( | |
245 | + [ | |
246 | + 'index', | |
247 | + 'product_id' => $product_id, | |
248 | + ] | |
249 | + ); | |
231 | 250 | } |
232 | 251 | } |
233 | 252 | } |
234 | 253 | $groups = $model->getTaxGroupsByLevel(1); |
235 | - return $this->render('update', [ | |
236 | - 'model' => $model, | |
237 | - 'modelLangs' => $model->modelLangs, | |
238 | - 'groups' => $groups, | |
239 | - 'stocks' => ( !empty( $model->variantStocks ) ) ? $model->variantStocks : [ new ProductStock ], | |
240 | - 'product' => $product, | |
241 | - ]); | |
254 | + return $this->render( | |
255 | + 'update', | |
256 | + [ | |
257 | + 'model' => $model, | |
258 | + 'modelLangs' => $model->modelLangs, | |
259 | + 'groups' => $groups, | |
260 | + 'stocks' => ( !empty( $model->variantStocks ) ) ? $model->variantStocks : [ new ProductStock ], | |
261 | + 'product' => $product, | |
262 | + ] | |
263 | + ); | |
242 | 264 | } |
243 | 265 | |
244 | 266 | /** |
... | ... | @@ -256,17 +278,19 @@ |
256 | 278 | $this->findModel($id) |
257 | 279 | ->delete(); |
258 | 280 | |
259 | - return $this->redirect([ | |
260 | - 'index', | |
261 | - 'product_id' => $product_id, | |
262 | - ]); | |
281 | + return $this->redirect( | |
282 | + [ | |
283 | + 'index', | |
284 | + 'product_id' => $product_id, | |
285 | + ] | |
286 | + ); | |
263 | 287 | } |
264 | 288 | |
265 | 289 | public function actionDelimg($id) |
266 | 290 | { |
267 | 291 | $image = ProductImage::findOne($id); |
268 | 292 | |
269 | - if($image) { | |
293 | + if ($image) { | |
270 | 294 | $image->delete(); |
271 | 295 | } |
272 | 296 | |
... | ... | @@ -285,10 +309,10 @@ |
285 | 309 | */ |
286 | 310 | protected function findModel($id) |
287 | 311 | { |
288 | - if(( $model = ProductVariant::find() | |
289 | - ->where([ 'product_variant_id' => $id ]) | |
290 | - ->with('lang') | |
291 | - ->one() ) !== NULL | |
312 | + if (( $model = ProductVariant::find() | |
313 | + ->where([ 'id' => $id ]) | |
314 | + ->with('lang') | |
315 | + ->one() ) !== null | |
292 | 316 | ) { |
293 | 317 | return $model; |
294 | 318 | } else { |
... | ... | @@ -304,10 +328,10 @@ |
304 | 328 | */ |
305 | 329 | protected function findProduct($product_id) |
306 | 330 | { |
307 | - if(( $model = Product::find() | |
308 | - ->with('lang') | |
309 | - ->where([ 'id' => $product_id ]) | |
310 | - ->one() ) !== NULL | |
331 | + if (( $model = Product::find() | |
332 | + ->with('lang') | |
333 | + ->where([ 'id' => $product_id ]) | |
334 | + ->one() ) !== null | |
311 | 335 | ) { |
312 | 336 | return $model; |
313 | 337 | } else { | ... | ... |
common/modules/product/helpers/ProductHelper.php
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | public static function getCategories() |
21 | 21 | { |
22 | 22 | return Category::find() |
23 | - ->getTree(NULL, 'lang'); | |
23 | + ->getTree(null, 'lang'); | |
24 | 24 | } |
25 | 25 | |
26 | 26 | public static function getBrands() |
... | ... | @@ -37,32 +37,40 @@ |
37 | 37 | public static function getFilterForOption($filter, $key, $value, $remove = false) |
38 | 38 | { |
39 | 39 | $result = $filter; |
40 | - if(is_array($value)) { | |
41 | - foreach($value as $value_key => $value_items) { | |
42 | - if(!is_array($value_items)) { | |
40 | + if (is_array($value)) { | |
41 | + foreach ($value as $value_key => $value_items) { | |
42 | + if (!is_array($value_items)) { | |
43 | 43 | $value_items = [ $value_items ]; |
44 | 44 | } |
45 | - foreach($value_items as $value_item) { | |
46 | - if($remove && isset( $result[ $key ] ) && ( $i = array_search($value_item, $result[ $key ][ $value_key ]) ) !== false) { | |
45 | + foreach ($value_items as $value_item) { | |
46 | + if ($remove && isset( $result[ $key ] ) && ( $i = array_search( | |
47 | + $value_item, | |
48 | + $result[ $key ][ $value_key ] | |
49 | + ) ) !== false | |
50 | + ) { | |
47 | 51 | unset( $result[ $key ][ $value_key ][ $i ] ); |
48 | - if(empty( $result[ $key ][ $value_key ] )) { | |
52 | + if (empty( $result[ $key ][ $value_key ] )) { | |
49 | 53 | unset( $result[ $key ][ $value_key ] ); |
50 | 54 | } |
51 | 55 | } else { |
52 | - if(!isset( $result[ $key ][ $value_key ] ) || array_search($value_item, $result[ $key ][ $value_key ]) === false) { | |
56 | + if (!isset( $result[ $key ][ $value_key ] ) || array_search( | |
57 | + $value_item, | |
58 | + $result[ $key ][ $value_key ] | |
59 | + ) === false | |
60 | + ) { | |
53 | 61 | $result[ $key ][ $value_key ][] = $value_item; |
54 | 62 | } |
55 | 63 | } |
56 | 64 | } |
57 | 65 | } |
58 | 66 | } else { |
59 | - if($remove && isset( $result[ $key ] ) && ( $i = array_search($value, $result[ $key ]) ) !== false) { | |
67 | + if ($remove && isset( $result[ $key ] ) && ( $i = array_search($value, $result[ $key ]) ) !== false) { | |
60 | 68 | unset( $result[ $key ][ $i ] ); |
61 | - if(empty( $result[ $key ] )) { | |
69 | + if (empty( $result[ $key ] )) { | |
62 | 70 | unset( $result[ $key ] ); |
63 | 71 | } |
64 | 72 | } else { |
65 | - if(!isset( $result[ $key ] ) || array_search($value, $result[ $key ]) === false) { | |
73 | + if (!isset( $result[ $key ] ) || array_search($value, $result[ $key ]) === false) { | |
66 | 74 | $result[ $key ][] = $value; |
67 | 75 | } |
68 | 76 | } |
... | ... | @@ -73,9 +81,9 @@ |
73 | 81 | public static function addLastProsucts($product_id) |
74 | 82 | { |
75 | 83 | $last_products = self::getLastProducts(); |
76 | - if(!in_array($product_id, $last_products)) { | |
84 | + if (!in_array($product_id, $last_products)) { | |
77 | 85 | $last_products[] = intval($product_id); |
78 | - if(count($last_products) > 16) { | |
86 | + if (count($last_products) > 16) { | |
79 | 87 | array_shift($last_products); |
80 | 88 | } |
81 | 89 | Yii::$app->session->set('last_products', $last_products); |
... | ... | @@ -85,24 +93,26 @@ |
85 | 93 | public static function getLastProducts($as_object = false) |
86 | 94 | { |
87 | 95 | $last_products = Yii::$app->session->get('last_products', []); |
88 | - if($as_object) { | |
96 | + if ($as_object) { | |
89 | 97 | $last_products = Product::find() |
90 | 98 | ->joinWith([ 'variant' ]) |
91 | 99 | ->where([ Product::tableName() . '.id' => $last_products ]) |
92 | - ->andWhere([ | |
93 | - '!=', | |
94 | - ProductVariant::tableName() . '.stock', | |
95 | - 0, | |
96 | - ]) | |
100 | + ->andWhere( | |
101 | + [ | |
102 | + '!=', | |
103 | + ProductVariant::tableName() . '.stock', | |
104 | + 0, | |
105 | + ] | |
106 | + ) | |
97 | 107 | ->all(); |
98 | 108 | } |
99 | 109 | return array_reverse($last_products); |
100 | 110 | } |
101 | 111 | |
102 | - public static function getSpecialProducts($type, $count, $sort = NULL) | |
112 | + public static function getSpecialProducts($type, $count, $sort = null) | |
103 | 113 | { |
104 | 114 | $data = []; |
105 | - switch($type) { | |
115 | + switch ($type) { | |
106 | 116 | case 'top': |
107 | 117 | $data = [ 'is_top' => true ]; |
108 | 118 | break; |
... | ... | @@ -110,18 +120,20 @@ |
110 | 120 | $data = [ 'is_new' => true ]; |
111 | 121 | break; |
112 | 122 | case 'promo': |
113 | - $data = [ 'akciya' => true ]; | |
123 | + $data = [ 'is_discount' => true ]; | |
114 | 124 | break; |
115 | 125 | } |
116 | 126 | return Product::find() |
117 | 127 | ->with('lang') |
118 | 128 | ->joinWith('variants.lang') |
119 | 129 | ->where($data) |
120 | - ->andWhere([ | |
121 | - '!=', | |
122 | - ProductVariant::tableName() . '.stock', | |
123 | - 0, | |
124 | - ]) | |
130 | + ->andWhere( | |
131 | + [ | |
132 | + '!=', | |
133 | + ProductVariant::tableName() . '.stock', | |
134 | + 0, | |
135 | + ] | |
136 | + ) | |
125 | 137 | ->limit($count) |
126 | 138 | ->all(); |
127 | 139 | } |
... | ... | @@ -134,51 +146,58 @@ |
134 | 146 | */ |
135 | 147 | public static function getSimilarProducts($product, $count = 10) |
136 | 148 | { |
137 | - if(!is_object($product)) { | |
149 | + if (!is_object($product)) { | |
138 | 150 | $product = Product::find() |
139 | 151 | ->where([ 'id' => $product ]) |
140 | 152 | ->with('enabledVariants') |
141 | 153 | ->one(); |
142 | 154 | } |
143 | 155 | |
144 | - if(!$product->properties) { | |
156 | + if (!$product->properties) { | |
145 | 157 | return []; |
146 | 158 | } |
147 | 159 | $product_categories = []; |
148 | - foreach($product->categories as $category) { | |
160 | + foreach ($product->categories as $category) { | |
149 | 161 | $product_categories[] = $category->id; |
150 | 162 | } |
151 | 163 | $query = Product::find() |
152 | 164 | ->select('product.id') |
153 | 165 | ->innerJoinWith('variant') |
154 | 166 | ->joinWith('category') |
155 | - ->where([ | |
156 | - '!=', | |
157 | - 'product_variant.stock', | |
158 | - 0, | |
159 | - ]) | |
167 | + ->where( | |
168 | + [ | |
169 | + '!=', | |
170 | + 'product_variant.stock', | |
171 | + 0, | |
172 | + ] | |
173 | + ) | |
160 | 174 | ->andWhere([ 'product_category.category_id' => $product_categories ]); |
161 | - foreach($product->properties as $group) { | |
175 | + foreach ($product->properties as $group) { | |
162 | 176 | $where = []; |
163 | - foreach($group->options as $option) { | |
177 | + foreach ($group->options as $option) { | |
164 | 178 | $where[] = $option->tax_option_id; |
165 | 179 | } |
166 | - if(!$where) { | |
180 | + if (!$where) { | |
167 | 181 | continue; |
168 | 182 | } |
169 | - $query->innerJoin('product_option to' . $group->tax_group_id, 'to' . $group->tax_group_id . '.product_id = product.id'); | |
183 | + $query->innerJoin( | |
184 | + 'product_option to' . $group->tax_group_id, | |
185 | + 'to' . $group->tax_group_id . '.product_id = product.id' | |
186 | + ); | |
170 | 187 | $query->andWhere([ 'to' . $group->tax_group_id . '.option_id' => $where ]); |
171 | 188 | } |
172 | - $query->andWhere([ | |
173 | - '!=', | |
174 | - 'product.id', | |
175 | - $product->id, | |
176 | - ]); | |
189 | + $query->andWhere( | |
190 | + [ | |
191 | + '!=', | |
192 | + 'product.id', | |
193 | + $product->id, | |
194 | + ] | |
195 | + ); | |
177 | 196 | $query->groupBy('product.id'); |
178 | 197 | $query->limit($count); |
179 | 198 | $products = $query->asArray() |
180 | 199 | ->all(); |
181 | - foreach($products as &$_product) { | |
200 | + foreach ($products as &$_product) { | |
182 | 201 | $_product = Product::findOne($_product[ 'id' ]); |
183 | 202 | } |
184 | 203 | return $products; |
... | ... | @@ -193,39 +212,47 @@ |
193 | 212 | */ |
194 | 213 | public static function setQueryParams(&$query, $params, $setPriceLimits = true) |
195 | 214 | { |
196 | - if(!empty( $params[ 'keywords' ] )) { | |
197 | - if(!is_array($params[ 'keywords' ])) { | |
215 | + if (!empty( $params[ 'keywords' ] )) { | |
216 | + if (!is_array($params[ 'keywords' ])) { | |
198 | 217 | $params[ 'keywords' ] = [ $params[ 'keywords' ] ]; |
199 | 218 | } |
200 | - foreach($params[ 'keywords' ] as $keyword) { | |
201 | - $query->orFilterWhere([ | |
202 | - 'ilike', | |
203 | - Product::tableName() . '.name', | |
204 | - $keyword, | |
205 | - ]); | |
206 | - $query->orFilterWhere([ | |
207 | - 'ilike', | |
208 | - Brand::tableName() . '.name', | |
209 | - $keyword, | |
210 | - ]); | |
211 | - $query->orFilterWhere([ | |
212 | - 'ilike', | |
213 | - Category::tableName() . '.name', | |
214 | - $keyword, | |
215 | - ]); | |
216 | - $query->orFilterWhere([ | |
217 | - 'ilike', | |
218 | - ProductVariant::tableName() . '.sku', | |
219 | - $keyword, | |
220 | - ]); | |
219 | + foreach ($params[ 'keywords' ] as $keyword) { | |
220 | + $query->orFilterWhere( | |
221 | + [ | |
222 | + 'ilike', | |
223 | + Product::tableName() . '.name', | |
224 | + $keyword, | |
225 | + ] | |
226 | + ); | |
227 | + $query->orFilterWhere( | |
228 | + [ | |
229 | + 'ilike', | |
230 | + Brand::tableName() . '.name', | |
231 | + $keyword, | |
232 | + ] | |
233 | + ); | |
234 | + $query->orFilterWhere( | |
235 | + [ | |
236 | + 'ilike', | |
237 | + Category::tableName() . '.name', | |
238 | + $keyword, | |
239 | + ] | |
240 | + ); | |
241 | + $query->orFilterWhere( | |
242 | + [ | |
243 | + 'ilike', | |
244 | + ProductVariant::tableName() . '.sku', | |
245 | + $keyword, | |
246 | + ] | |
247 | + ); | |
221 | 248 | } |
222 | 249 | } |
223 | 250 | |
224 | - foreach($params as $key => $param) { | |
251 | + foreach ($params as $key => $param) { | |
225 | 252 | |
226 | - switch($key) { | |
253 | + switch ($key) { | |
227 | 254 | case 'special': |
228 | - foreach($param as $inner_key => $value) { | |
255 | + foreach ($param as $inner_key => $value) { | |
229 | 256 | $query->orFilterWhere([ Product::tableName() . '.' . $inner_key => $value ]); |
230 | 257 | } |
231 | 258 | break; |
... | ... | @@ -235,42 +262,54 @@ |
235 | 262 | case 'keywords': |
236 | 263 | break; |
237 | 264 | case 'prices': |
238 | - if($param[ 'min' ] > 0) { | |
239 | - $query->andWhere([ | |
240 | - '>=', | |
241 | - ProductVariant::tableName() . '.price', | |
242 | - $param[ 'min' ], | |
243 | - ]); | |
265 | + if ($param[ 'min' ] > 0) { | |
266 | + $query->andWhere( | |
267 | + [ | |
268 | + '>=', | |
269 | + ProductVariant::tableName() . '.price', | |
270 | + $param[ 'min' ], | |
271 | + ] | |
272 | + ); | |
244 | 273 | } |
245 | - if($param[ 'max' ] > 0) { | |
246 | - $query->andWhere([ | |
247 | - '<=', | |
248 | - ProductVariant::tableName() . '.price', | |
249 | - $param[ 'max' ], | |
250 | - ]); | |
274 | + if ($param[ 'max' ] > 0) { | |
275 | + $query->andWhere( | |
276 | + [ | |
277 | + '<=', | |
278 | + ProductVariant::tableName() . '.price', | |
279 | + $param[ 'max' ], | |
280 | + ] | |
281 | + ); | |
251 | 282 | } |
252 | 283 | break; |
253 | 284 | default: |
254 | 285 | /** |
255 | 286 | * @todo Refactor this |
256 | 287 | */ |
257 | - $query->andWhere(Product::tableName() . '.id IN ( | |
288 | + $query->andWhere( | |
289 | + Product::tableName() . '.id IN ( | |
258 | 290 | SELECT DISTINCT products |
259 | 291 | FROM ( |
260 | 292 | SELECT id AS products |
261 | 293 | FROM product_option |
262 | 294 | INNER JOIN tax_option ON tax_option.tax_option_id = product_option.option_id |
263 | 295 | INNER JOIN tax_group ON tax_group.tax_group_id = tax_option.tax_group_id |
264 | - WHERE tax_group.alias LIKE \'' . $key . '\' AND tax_option.alias IN (\'' . implode('\',\'', $param) . '\') OR product_id IN ( | |
296 | + WHERE tax_group.alias LIKE \'' . $key . '\' AND tax_option.alias IN (\'' . implode( | |
297 | + '\',\'', | |
298 | + $param | |
299 | + ) . '\') OR product_id IN ( | |
265 | 300 | (SELECT product_id AS products |
266 | 301 | FROM product_variant_option |
267 | - INNER JOIN product_variant ON product_variant_option.product_variant_id = product_variant.product_variant_id | |
302 | + INNER JOIN product_variant ON product_variant_option.product_variant_id = product_variant.id | |
268 | 303 | INNER JOIN tax_option ON tax_option.tax_option_id = product_variant_option.option_id |
269 | 304 | INNER JOIN tax_group ON tax_group.tax_group_id = tax_option.tax_group_id |
270 | - WHERE tax_group.alias LIKE \'' . $key . '\' AND tax_option.alias IN (\'' . implode('\',\'', $param) . '\')) | |
305 | + WHERE tax_group.alias LIKE \'' . $key . '\' AND tax_option.alias IN (\'' . implode( | |
306 | + '\',\'', | |
307 | + $param | |
308 | + ) . '\')) | |
271 | 309 | ) |
272 | 310 | ) AS table_name |
273 | - )'); | |
311 | + )' | |
312 | + ); | |
274 | 313 | break; |
275 | 314 | } |
276 | 315 | |
... | ... | @@ -285,16 +324,16 @@ |
285 | 324 | * |
286 | 325 | * @return ActiveQuery |
287 | 326 | */ |
288 | - public static function productCountQuery($category = NULL, $params, $excludeKeys = []) | |
327 | + public static function productCountQuery($category = null, $params, $excludeKeys = []) | |
289 | 328 | { |
290 | 329 | $p = []; |
291 | - foreach($params as $key => $param) { | |
292 | - if(in_array($key, $excludeKeys)) { | |
330 | + foreach ($params as $key => $param) { | |
331 | + if (in_array($key, $excludeKeys)) { | |
293 | 332 | $p[ $key ] = $param; |
294 | 333 | } |
295 | 334 | } |
296 | 335 | /** @var ActiveQuery $query */ |
297 | - if(!empty( $category )) { | |
336 | + if (!empty( $category )) { | |
298 | 337 | $query = $category->getProducts(); |
299 | 338 | } else { |
300 | 339 | $query = Product::find(); | ... | ... |
common/modules/product/models/Category.php
... | ... | @@ -14,6 +14,7 @@ |
14 | 14 | |
15 | 15 | /** |
16 | 16 | * This is the model class for table "category". |
17 | + * | |
17 | 18 | * @todo Write doc for ArtboxTreeBehavior |
18 | 19 | * @property integer $category_id |
19 | 20 | * @property integer $remote_id |
... | ... | @@ -25,7 +26,7 @@ |
25 | 26 | * @property Product[] $products |
26 | 27 | * @property ProductUnit $productUnit |
27 | 28 | * @property ProductCategory[] $productCategories |
28 | - * * From language behavior * | |
29 | + * * From language behavior * | |
29 | 30 | * @property CategoryLang $lang |
30 | 31 | * @property CategoryLang[] $langs |
31 | 32 | * @property CategoryLang $objectLang |
... | ... | @@ -44,13 +45,13 @@ |
44 | 45 | * @method bool linkLangs() |
45 | 46 | * @method bool saveLangs() |
46 | 47 | * @method bool getTransactionStatus() |
47 | - * * End language behavior * | |
48 | - * * From SaveImgBehavior | |
48 | + * * End language behavior * | |
49 | + * * From SaveImgBehavior | |
49 | 50 | * @property string|null $imageFile |
50 | 51 | * @property string|null $imageUrl |
51 | 52 | * @method string|null getImageFile( int $field ) |
52 | 53 | * @method string|null getImageUrl( int $field ) |
53 | - * * End SaveImgBehavior | |
54 | + * * End SaveImgBehavior | |
54 | 55 | */ |
55 | 56 | class Category extends ActiveRecord |
56 | 57 | { |
... | ... | @@ -60,7 +61,7 @@ |
60 | 61 | return [ |
61 | 62 | 'artboxtree' => [ |
62 | 63 | 'class' => ArtboxTreeBehavior::className(), |
63 | - 'keyNameGroup' => NULL, | |
64 | + 'keyNameGroup' => null, | |
64 | 65 | 'keyNamePath' => 'path', |
65 | 66 | ], |
66 | 67 | 'language' => [ |
... | ... | @@ -115,7 +116,7 @@ |
115 | 116 | public function attributeLabels() |
116 | 117 | { |
117 | 118 | return [ |
118 | - 'id' => Yii::t('product', 'Category ID'), | |
119 | + 'id' => Yii::t('product', 'Category ID'), | |
119 | 120 | 'parent_id' => Yii::t('product', 'Parent ID'), |
120 | 121 | 'path' => Yii::t('product', 'Path'), |
121 | 122 | 'depth' => Yii::t('product', 'Depth'), |
... | ... | @@ -136,7 +137,7 @@ |
136 | 137 | */ |
137 | 138 | public function getProductUnit() |
138 | 139 | { |
139 | - return $this->hasOne(ProductUnit::className(), [ 'product_unit_id' => 'product_unit_id' ]); | |
140 | + return $this->hasOne(ProductUnit::className(), [ 'id' => 'product_unit_id' ]); | |
140 | 141 | } |
141 | 142 | |
142 | 143 | public function getProducts() |
... | ... | @@ -171,9 +172,9 @@ |
171 | 172 | |
172 | 173 | public function beforeSave($insert) |
173 | 174 | { |
174 | - if(parent::beforeSave($insert)) { | |
175 | + if (parent::beforeSave($insert)) { | |
175 | 176 | |
176 | - if(empty( $this->parent_id )) { | |
177 | + if (empty( $this->parent_id )) { | |
177 | 178 | $this->parent_id = 0; |
178 | 179 | } |
179 | 180 | |
... | ... | @@ -185,53 +186,76 @@ |
185 | 186 | public function getActiveFilters() |
186 | 187 | { |
187 | 188 | $query1 = ( new Query() )->distinct() |
188 | - ->select([ | |
189 | - 'option_id', | |
190 | - ]) | |
189 | + ->select( | |
190 | + [ | |
191 | + 'option_id', | |
192 | + ] | |
193 | + ) | |
191 | 194 | ->from('tax_option') |
192 | - ->innerJoin('product_variant_option', 'tax_option.tax_option_id = product_variant_option.option_id') | |
195 | + ->innerJoin( | |
196 | + 'product_variant_option', | |
197 | + 'tax_option.tax_option_id = product_variant_option.option_id' | |
198 | + ) | |
193 | 199 | ->innerJoin('tax_group', 'tax_group.tax_group_id = tax_option.tax_group_id') |
194 | - ->innerJoin('product_variant', 'product_variant.product_variant_id = product_variant_option.product_variant_id') | |
200 | + ->innerJoin( | |
201 | + 'product_variant', | |
202 | + 'product_variant.id = product_variant_option.product_variant_id' | |
203 | + ) | |
195 | 204 | ->innerJoin('product', 'product.id = product_variant.product_id') |
196 | 205 | ->innerJoin('product_category', 'product_category.product_id = product.id') |
197 | - ->where([ | |
198 | - 'product_category.category_id' => $this->id, | |
199 | - 'tax_group.is_filter' => true, | |
200 | - ]) | |
201 | - ->andWhere([ | |
202 | - '!=', | |
203 | - 'product_variant.stock', | |
204 | - 0, | |
205 | - ]); | |
206 | + ->where( | |
207 | + [ | |
208 | + 'product_category.category_id' => $this->id, | |
209 | + 'tax_group.is_filter' => true, | |
210 | + ] | |
211 | + ) | |
212 | + ->andWhere( | |
213 | + [ | |
214 | + '!=', | |
215 | + 'product_variant.stock', | |
216 | + 0, | |
217 | + ] | |
218 | + ); | |
206 | 219 | |
207 | 220 | $query2 = ( new Query() )->distinct() |
208 | - ->select([ | |
209 | - 'option_id', | |
210 | - ]) | |
221 | + ->select( | |
222 | + [ | |
223 | + 'option_id', | |
224 | + ] | |
225 | + ) | |
211 | 226 | ->from('tax_option') |
212 | - ->innerJoin('product_option', 'tax_option.tax_option_id = product_option.option_id') | |
227 | + ->innerJoin( | |
228 | + 'product_option', | |
229 | + 'tax_option.tax_option_id = product_option.option_id' | |
230 | + ) | |
213 | 231 | ->innerJoin('tax_group', 'tax_group.tax_group_id = tax_option.tax_group_id') |
214 | 232 | ->innerJoin('product', 'product.id = product_option.product_id') |
215 | 233 | ->innerJoin('product_category', 'product_category.product_id = product.id') |
216 | 234 | ->innerJoin('product_variant', 'product_variant.product_id = product.id') |
217 | - ->where([ | |
218 | - 'product_category.category_id' => $this->id, | |
219 | - 'tax_group.is_filter' => true, | |
220 | - ]) | |
221 | - ->andWhere([ | |
222 | - '!=', | |
223 | - 'product_variant.stock', | |
224 | - 0, | |
225 | - ]); | |
226 | - $query3 = ( new Query() )->select([ | |
227 | - 'tax_option.*', | |
228 | - 'tax_group.*', | |
229 | - 'tax_option.alias as option_alias', | |
230 | - 'tax_group.alias as group_alias', | |
231 | - 'tax_option.value as value', | |
232 | - 'tax_option.sort AS tax_option_sort', | |
233 | - 'tax_group.sort AS tax_group_sort', | |
234 | - ]) | |
235 | + ->where( | |
236 | + [ | |
237 | + 'product_category.category_id' => $this->id, | |
238 | + 'tax_group.is_filter' => true, | |
239 | + ] | |
240 | + ) | |
241 | + ->andWhere( | |
242 | + [ | |
243 | + '!=', | |
244 | + 'product_variant.stock', | |
245 | + 0, | |
246 | + ] | |
247 | + ); | |
248 | + $query3 = ( new Query() )->select( | |
249 | + [ | |
250 | + 'tax_option.*', | |
251 | + 'tax_group.*', | |
252 | + 'tax_option.alias as option_alias', | |
253 | + 'tax_group.alias as group_alias', | |
254 | + 'tax_option.value as value', | |
255 | + 'tax_option.sort AS tax_option_sort', | |
256 | + 'tax_group.sort AS tax_group_sort', | |
257 | + ] | |
258 | + ) | |
235 | 259 | ->from([ 'tax_option' ]) |
236 | 260 | ->where([ 'tax_option.tax_option_id' => $query1->union($query2) ]) |
237 | 261 | ->innerJoin('tax_group', 'tax_group.tax_group_id = tax_option.tax_group_id') |
... | ... | @@ -242,7 +266,8 @@ |
242 | 266 | public function getTaxGroupsForMenu() |
243 | 267 | { |
244 | 268 | $connection = Yii::$app->getDb(); |
245 | - $command = $connection->createCommand(' | |
269 | + $command = $connection->createCommand( | |
270 | + ' | |
246 | 271 | SELECT ton.alias AS option_alias, * |
247 | 272 | FROM tax_option AS ton |
248 | 273 | RIGHT JOIN tax_group ON ton.tax_group_id = tax_group.tax_group_id |
... | ... | @@ -253,10 +278,12 @@ |
253 | 278 | SELECT product_id FROM product_category WHERE category_id = :category_id |
254 | 279 | ) |
255 | 280 | ) |
256 | - AND tax_group.is_menu = TRUE AND tax_group_to_category.category_id = :category_id', [ | |
257 | - ':category_id' => $this->id, | |
258 | - | |
259 | - ]); | |
281 | + AND tax_group.is_menu = TRUE AND tax_group_to_category.category_id = :category_id', | |
282 | + [ | |
283 | + ':category_id' => $this->id, | |
284 | + | |
285 | + ] | |
286 | + ); | |
260 | 287 | return $command->queryAll(); |
261 | 288 | } |
262 | 289 | ... | ... |
common/modules/product/models/Export.php
... | ... | @@ -32,11 +32,11 @@ |
32 | 32 | ]; |
33 | 33 | } |
34 | 34 | |
35 | - public function process($filename = NULL, $from = 0) | |
35 | + public function process($filename = null, $from = 0) | |
36 | 36 | { |
37 | 37 | $limit = 100; |
38 | 38 | |
39 | - if(empty( $filename )) { | |
39 | + if (empty( $filename )) { | |
40 | 40 | $filename = 'products_' . date('d_m_Y_H_i') . '.csv'; |
41 | 41 | $handle = fopen(\Yii::getAlias('@storage/sync/') . $filename, "w"); |
42 | 42 | } else { |
... | ... | @@ -58,25 +58,29 @@ |
58 | 58 | $filesize = Product::find() |
59 | 59 | ->joinWith('lang', true, 'INNER JOIN') |
60 | 60 | ->count(); |
61 | - foreach($products as $product) { | |
61 | + foreach ($products as $product) { | |
62 | 62 | $mods = []; |
63 | 63 | $filterString = $this->convertFilterToString($product->filters); |
64 | 64 | |
65 | - foreach($product->variantsWithFilters as $variant) { | |
65 | + foreach ($product->variantsWithFilters as $variant) { | |
66 | 66 | /** |
67 | 67 | * @var ProductVariant $variant |
68 | 68 | */ |
69 | 69 | $color = $variant->lang->title; |
70 | - $mods[] = $variant->sku . $this->generateID($variant->remote_id) . '=' . $this->convertFilterToString($variant->filters) . '=' . $color . '=' . ( ( !empty( $variant->image ) ) ? $variant->image->image : '' ) . '=' . $variant->stock; | |
70 | + $mods[] = $variant->sku . $this->generateID( | |
71 | + $variant->remote_id | |
72 | + ) . '=' . $this->convertFilterToString( | |
73 | + $variant->filters | |
74 | + ) . '=' . $color . '=' . ( ( !empty( $variant->image ) ) ? $variant->image->image : '' ) . '=' . $variant->stock; | |
71 | 75 | } |
72 | 76 | |
73 | 77 | $fotos = []; |
74 | - foreach($product->images as $image) { | |
78 | + foreach ($product->images as $image) { | |
75 | 79 | $fotos[] = $image->image; |
76 | 80 | } |
77 | 81 | |
78 | 82 | $categories = []; |
79 | - foreach($product->categories as $value) { | |
83 | + foreach ($product->categories as $value) { | |
80 | 84 | $categories[] = $value->lang->title . $this->generateID($value->remote_id); |
81 | 85 | } |
82 | 86 | |
... | ... | @@ -85,7 +89,9 @@ |
85 | 89 | $list = [ |
86 | 90 | $categories, |
87 | 91 | //A - ะบะฐัะตะณะพัะธะธ ัะตัะตะท ะทะฐะฟัััั ะะฐะทะฒะฐะฝะธะต(remote_id) |
88 | - ( ( !empty( $product->brand ) ) ? $product->brand->lang->title . $this->generateID($product->brand->remote_id) : '' ), | |
92 | + ( ( !empty( $product->brand ) ) ? $product->brand->lang->title . $this->generateID( | |
93 | + $product->brand->remote_id | |
94 | + ) : '' ), | |
89 | 95 | //B - ะฑัะตะฝะด ะะฐะทะฒะฐะฝะธะต(remote_id) |
90 | 96 | $product->lang->title . $this->generateID($product->remote_id), |
91 | 97 | //C - ะฝะฐะทะฒะฐะฝะธะต ัะพะฒะฐัะฐ ะะฐะทะฒะฐะฝะธะต(remote_id) |
... | ... | @@ -97,7 +103,7 @@ |
97 | 103 | //F - ัััะฐัะฐั ัะตะฝะฐ |
98 | 104 | ( !empty( $product->variant ) ) ? $product->variant->price : '', |
99 | 105 | //G - ะฝะพะฒะฐั ัะตะฝะฐ |
100 | - intval($product->akciya), | |
106 | + intval($product->is_discount), | |
101 | 107 | //H - ัะพะฒะฐั ะฐะบัะธะพะฝะฝัะน (1/0) |
102 | 108 | '', |
103 | 109 | //I - ะฟัััะพะน |
... | ... | @@ -120,7 +126,7 @@ |
120 | 126 | |
121 | 127 | $from += $limit; |
122 | 128 | $end = false; |
123 | - if($from > $filesize) { | |
129 | + if ($from > $filesize) { | |
124 | 130 | $end = true; |
125 | 131 | } |
126 | 132 | |
... | ... | @@ -131,10 +137,13 @@ |
131 | 137 | 'filename' => $filename, |
132 | 138 | ]; |
133 | 139 | |
134 | - if($end) { | |
135 | - $result = array_merge($result, [ | |
136 | - 'link' => '/storage/sync/' . $filename, | |
137 | - ]); | |
140 | + if ($end) { | |
141 | + $result = array_merge( | |
142 | + $result, | |
143 | + [ | |
144 | + 'link' => '/storage/sync/' . $filename, | |
145 | + ] | |
146 | + ); | |
138 | 147 | } |
139 | 148 | |
140 | 149 | return $result; |
... | ... | @@ -147,12 +156,14 @@ |
147 | 156 | /** |
148 | 157 | * @var TaxOption[] $filters |
149 | 158 | */ |
150 | - foreach($filters as $filter) { | |
151 | - $fittersArray[ $filter->taxGroup->lang->title . $this->generateID($filter->taxGroup->remote_id) ][] = $filter->lang->value . $this->generateID($filter->remote_id); | |
159 | + foreach ($filters as $filter) { | |
160 | + $fittersArray[ $filter->taxGroup->lang->title . $this->generateID( | |
161 | + $filter->taxGroup->remote_id | |
162 | + ) ][] = $filter->lang->value . $this->generateID($filter->remote_id); | |
152 | 163 | } |
153 | 164 | $filterString = []; |
154 | 165 | |
155 | - foreach($fittersArray as $filterName => $filterRows) { | |
166 | + foreach ($fittersArray as $filterName => $filterRows) { | |
156 | 167 | $row = implode(',', $filterRows); |
157 | 168 | $filterString[] = "[{$filterName}:{$row}]"; |
158 | 169 | } | ... | ... |
common/modules/product/models/Import.php
... | ... | @@ -63,33 +63,42 @@ |
63 | 63 | |
64 | 64 | public function getType() |
65 | 65 | { |
66 | - if(!$this->type) { | |
66 | + if (!$this->type) { | |
67 | 67 | $this->type = 'products'; |
68 | 68 | } |
69 | 69 | return $this->type; |
70 | 70 | } |
71 | 71 | |
72 | - public function goPrices($from = 0, $limit = NULL) | |
72 | + public function goPrices($from = 0, $limit = null) | |
73 | 73 | { |
74 | 74 | set_time_limit(0); |
75 | 75 | |
76 | - if(!( $handle = $this->getProductsFile('uploadFilePrices') )) { | |
76 | + if (!( $handle = $this->getProductsFile('uploadFilePrices') )) { | |
77 | 77 | $this->errors[] = 'File not found'; |
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
81 | 81 | $filesize = filesize(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFilePrices')); |
82 | - if($from) { | |
82 | + if ($from) { | |
83 | 83 | fseek($handle, $from); |
84 | 84 | } |
85 | 85 | |
86 | 86 | $j = 0; |
87 | 87 | |
88 | - $is_utf = ( preg_match('//u', file_get_contents(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFilePrices'), NULL, NULL, NULL, 1000000)) ); | |
88 | + $is_utf = ( preg_match( | |
89 | + '//u', | |
90 | + file_get_contents( | |
91 | + Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFilePrices'), | |
92 | + null, | |
93 | + null, | |
94 | + null, | |
95 | + 1000000 | |
96 | + ) | |
97 | + ) ); | |
89 | 98 | |
90 | - while(( empty( $limit ) || $j++ < $limit ) && ( $data = fgetcsv($handle, 10000, ";") ) !== false) { | |
91 | - foreach($data as &$value) { | |
92 | - if(!$is_utf) { | |
99 | + while (( empty( $limit ) || $j++ < $limit ) && ( $data = fgetcsv($handle, 10000, ";") ) !== false) { | |
100 | + foreach ($data as &$value) { | |
101 | + if (!$is_utf) { | |
93 | 102 | $value = iconv('windows-1251', "UTF-8//TRANSLIT//IGNORE", $value); |
94 | 103 | } |
95 | 104 | $value = trim($value); |
... | ... | @@ -103,29 +112,29 @@ |
103 | 112 | $city_name = @$data[ 4 ]; |
104 | 113 | $product_title = @$data[ 5 ]; |
105 | 114 | |
106 | - if(empty ( $modification_code )) { | |
115 | + if (empty ( $modification_code )) { | |
107 | 116 | continue; |
108 | 117 | } |
109 | 118 | // ัะพะฒะฐัั ะฒ ะฟััะธ |
110 | - if(empty ( $city_name )) { | |
119 | + if (empty ( $city_name )) { | |
111 | 120 | $this->output[] = 'ะขะพะฒะฐั ' . $product_title . ' ะฒ ะฟััะธ'; |
112 | 121 | continue; |
113 | 122 | } |
114 | 123 | /** |
115 | 124 | * @var ProductVariant $productVariant |
116 | 125 | */ |
117 | - if(( $productVariant = ProductVariant::find() | |
118 | - ->filterWhere([ 'sku' => $modification_code ]) | |
119 | - ->one() ) === NULL | |
126 | + if (( $productVariant = ProductVariant::find() | |
127 | + ->filterWhere([ 'sku' => $modification_code ]) | |
128 | + ->one() ) === null | |
120 | 129 | ) { |
121 | 130 | $this->output[] = 'ะะปั ัะพะฒะฐัะฐ ' . $product_title . ' ะฝะต ะฝะฐะนะดะตะฝะพ ัะพะพัะฒะตััะฒะธะต'; |
122 | 131 | continue; |
123 | 132 | } |
124 | 133 | // ===== Set stock ==== |
125 | - if($city_name) { | |
126 | - if(( $stock = Stock::find() | |
127 | - ->filterWhere([ 'title' => trim($city_name) ]) | |
128 | - ->one() ) === NULL | |
134 | + if ($city_name) { | |
135 | + if (( $stock = Stock::find() | |
136 | + ->filterWhere([ 'title' => trim($city_name) ]) | |
137 | + ->one() ) === null | |
129 | 138 | ) { |
130 | 139 | // Create stock |
131 | 140 | $stock = new Stock(); |
... | ... | @@ -134,37 +143,44 @@ |
134 | 143 | } |
135 | 144 | |
136 | 145 | $productStock = ProductStock::find() |
137 | - ->where([ | |
138 | - 'product_variant_id' => $productVariant->product_variant_id, | |
139 | - 'stock_id' => $stock->stock_id, | |
140 | - ]) | |
146 | + ->where( | |
147 | + [ | |
148 | + 'product_variant_id' => $productVariant->id, | |
149 | + 'stock_id' => $stock->id, | |
150 | + ] | |
151 | + ) | |
141 | 152 | ->one(); |
142 | - if(!$productStock instanceof ProductStock) { | |
143 | - $productStock = new ProductStock; | |
144 | - $productStock->product_variant_id = $productVariant->product_variant_id; | |
145 | - $productStock->stock_id = $stock->stock_id; | |
146 | - $productStock->product_id = $productVariant->product_id; | |
153 | + if (!$productStock instanceof ProductStock) { | |
154 | + $productStock = new ProductStock(); | |
155 | + $productStock->product_variant_id = $productVariant->id; | |
156 | + $productStock->stock_id = $stock->id; | |
147 | 157 | } |
148 | 158 | $productStock->quantity = $count; |
149 | 159 | |
150 | 160 | $productStock->save(false); |
151 | 161 | $productStocks = ProductStock::find() |
152 | - ->where([ 'product_variant_id' => $productVariant->product_variant_id ]) | |
153 | - ->andWhere([ | |
154 | - '<>', | |
155 | - 'stock_id', | |
156 | - $stock->stock_id, | |
157 | - ]) | |
162 | + ->where( | |
163 | + [ 'product_variant_id' => $productVariant->id ] | |
164 | + ) | |
165 | + ->andWhere( | |
166 | + [ | |
167 | + '<>', | |
168 | + 'stock_id', | |
169 | + $stock->id, | |
170 | + ] | |
171 | + ) | |
158 | 172 | ->all(); |
159 | 173 | |
160 | 174 | $quantity = array_sum(ArrayHelper::getColumn($productStocks, 'quantity')) + $count; |
161 | 175 | } else { |
162 | 176 | |
163 | 177 | $productStocks = ProductStock::find() |
164 | - ->where([ 'product_variant_id' => $productVariant->product_variant_id ]) | |
178 | + ->where( | |
179 | + [ 'product_variant_id' => $productVariant->id ] | |
180 | + ) | |
165 | 181 | ->all(); |
166 | 182 | |
167 | - if($productStocks instanceof ProductStock) { | |
183 | + if ($productStocks instanceof ProductStock) { | |
168 | 184 | $quantity = array_sum(ArrayHelper::getColumn($productStocks, 'quantity')) + $count; |
169 | 185 | } else { |
170 | 186 | $quantity = 0; |
... | ... | @@ -172,7 +188,7 @@ |
172 | 188 | |
173 | 189 | } |
174 | 190 | |
175 | - if($price_promo) { | |
191 | + if ($price_promo) { | |
176 | 192 | $productVariant->price_old = $price; |
177 | 193 | $productVariant->price = $price_promo; |
178 | 194 | } else { |
... | ... | @@ -197,7 +213,7 @@ |
197 | 213 | |
198 | 214 | fclose($handle); |
199 | 215 | |
200 | - if($result[ 'end' ]) { | |
216 | + if ($result[ 'end' ]) { | |
201 | 217 | unlink(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFilePrices')); |
202 | 218 | } |
203 | 219 | |
... | ... | @@ -214,8 +230,8 @@ |
214 | 230 | $pattern = '/^(?P<name>.*)(?:\(#(?P<remote_id>\w+)#\))?$/U'; |
215 | 231 | $name = trim($name); |
216 | 232 | $matches = []; |
217 | - if(preg_match($pattern, $name, $matches)) { | |
218 | - if(!isset( $matches[ 'remote_id' ] )) { | |
233 | + if (preg_match($pattern, $name, $matches)) { | |
234 | + if (!isset( $matches[ 'remote_id' ] )) { | |
219 | 235 | $matches[ 'remote_id' ] = ''; |
220 | 236 | } |
221 | 237 | return $matches; |
... | ... | @@ -236,19 +252,24 @@ |
236 | 252 | { |
237 | 253 | $category_id = []; |
238 | 254 | |
239 | - foreach($catalog_names as $catalog_name) { | |
255 | + foreach ($catalog_names as $catalog_name) { | |
240 | 256 | // ==== Set category ==== |
241 | 257 | $parsed_name = $this->parseName($catalog_name); |
242 | - if(!empty( $parsed_name[ 'remote_id' ] ) && ( $category = Category::find() | |
243 | - ->joinWith('lang') | |
244 | - ->andFilterWhere([ 'remote_id' => $parsed_name[ 'remote_id' ] ]) | |
245 | - ->one() ) !== NULL | |
258 | + if (!empty( $parsed_name[ 'remote_id' ] ) && ( $category = Category::find() | |
259 | + ->joinWith('lang') | |
260 | + ->andFilterWhere( | |
261 | + [ 'remote_id' => $parsed_name[ 'remote_id' ] ] | |
262 | + ) | |
263 | + ->one() ) !== null | |
246 | 264 | ) { |
247 | - if(!empty( $category->lang )) { | |
265 | + if (!empty( $category->lang )) { | |
248 | 266 | $category->lang->title = $parsed_name[ 'name' ]; |
249 | 267 | $category->lang->save(false); |
250 | 268 | } else { |
251 | - throw new \Exception('Category with ID ' . $category->id . ' and lang ' . Language::getCurrent()->id . ' doesn\'t exist'); | |
269 | + throw new \Exception( | |
270 | + 'Category with ID ' . $category->id . ' and lang ' . Language::getCurrent( | |
271 | + )->id . ' doesn\'t exist' | |
272 | + ); | |
252 | 273 | } |
253 | 274 | |
254 | 275 | } else { |
... | ... | @@ -256,7 +277,7 @@ |
256 | 277 | $category = new Category(); |
257 | 278 | $category->generateLangs(); |
258 | 279 | $category_langs = $category->modelLangs; |
259 | - foreach($category_langs as $category_lang) { | |
280 | + foreach ($category_langs as $category_lang) { | |
260 | 281 | $category_lang->title = $parsed_name[ 'name' ]; |
261 | 282 | } |
262 | 283 | $category->remote_id = $parsed_name[ 'remote_id' ]; |
... | ... | @@ -273,24 +294,29 @@ |
273 | 294 | * @return int|null |
274 | 295 | * @throws \Exception |
275 | 296 | */ |
276 | - private function saveBrand(string $brand_name = NULL):int | |
297 | + private function saveBrand(string $brand_name = null):int | |
277 | 298 | { |
278 | 299 | |
279 | 300 | $parsed_name = $this->parseName($brand_name); |
280 | - if(!empty( $brand_name )) { | |
301 | + if (!empty( $brand_name )) { | |
281 | 302 | /** |
282 | 303 | * @var Brand $brand |
283 | 304 | */ |
284 | - if(!empty( $parsed_name[ 'remote_id' ] ) && ( $brand = Brand::find() | |
285 | - ->joinWith('lang') | |
286 | - ->andFilterWhere([ 'remote_id' => $parsed_name[ 'remote_id' ] ]) | |
287 | - ->one() ) !== NULL | |
305 | + if (!empty( $parsed_name[ 'remote_id' ] ) && ( $brand = Brand::find() | |
306 | + ->joinWith('lang') | |
307 | + ->andFilterWhere( | |
308 | + [ 'remote_id' => $parsed_name[ 'remote_id' ] ] | |
309 | + ) | |
310 | + ->one() ) !== null | |
288 | 311 | ) { |
289 | - if(!empty( $brand->lang )) { | |
312 | + if (!empty( $brand->lang )) { | |
290 | 313 | $brand->lang->title = $parsed_name[ 'name' ]; |
291 | 314 | $brand->lang->save(false); |
292 | 315 | } else { |
293 | - throw new \Exception('Brand with ID ' . $brand->id . ' and lang ' . Language::getCurrent()->id . ' doesn\'t exist'); | |
316 | + throw new \Exception( | |
317 | + 'Brand with ID ' . $brand->id . ' and lang ' . Language::getCurrent( | |
318 | + )->id . ' doesn\'t exist' | |
319 | + ); | |
294 | 320 | } |
295 | 321 | return $brand->id; |
296 | 322 | } else { |
... | ... | @@ -298,7 +324,7 @@ |
298 | 324 | $brand = new Brand(); |
299 | 325 | $brand->generateLangs(); |
300 | 326 | $brand_langs = $brand->modelLangs; |
301 | - foreach($brand_langs as $brand_lang) { | |
327 | + foreach ($brand_langs as $brand_lang) { | |
302 | 328 | $brand_lang->title = $parsed_name[ 'name' ]; |
303 | 329 | } |
304 | 330 | $brand->remote_id = $parsed_name[ 'remote_id' ]; |
... | ... | @@ -306,7 +332,7 @@ |
306 | 332 | return $brand->id; |
307 | 333 | } |
308 | 334 | } |
309 | - return NULL; | |
335 | + return null; | |
310 | 336 | } |
311 | 337 | |
312 | 338 | /** |
... | ... | @@ -314,21 +340,23 @@ |
314 | 340 | * @param int $product_id |
315 | 341 | * @param int $product_variant_id |
316 | 342 | */ |
317 | - private function saveFotos(array $fotos, int $product_id, int $product_variant_id = NULL) | |
343 | + private function saveFotos(array $fotos, int $product_id, int $product_variant_id = null) | |
318 | 344 | { |
319 | - if(!empty( $fotos )) { | |
320 | - foreach($fotos as $foto) { | |
345 | + if (!empty( $fotos )) { | |
346 | + foreach ($fotos as $foto) { | |
321 | 347 | |
322 | - if(empty( $foto )) { | |
348 | + if (empty( $foto )) { | |
323 | 349 | continue; |
324 | 350 | } |
325 | 351 | $source_image = Yii::getAlias('@uploadDir') . '/product_images/' . urlencode($foto); |
326 | - if(file_exists($source_image)) { | |
327 | - if(( $productImage = ProductImage::find() | |
328 | - ->andWhere([ 'image' => $foto ]) | |
329 | - ->andWhere([ 'product_id' => $product_id ]) | |
330 | - ->andFilterWhere([ 'product_variant_id' => $product_variant_id ]) | |
331 | - ->one() ) === NULL | |
352 | + if (file_exists($source_image)) { | |
353 | + if (( $productImage = ProductImage::find() | |
354 | + ->andWhere([ 'image' => $foto ]) | |
355 | + ->andWhere([ 'product_id' => $product_id ]) | |
356 | + ->andFilterWhere( | |
357 | + [ 'product_variant_id' => $product_variant_id ] | |
358 | + ) | |
359 | + ->one() ) === null | |
332 | 360 | ) { |
333 | 361 | copy($source_image, Yii::getAlias('@productsDir') . "/" . $foto); |
334 | 362 | $productImage = new ProductImage(); |
... | ... | @@ -352,17 +380,23 @@ |
352 | 380 | * @return array |
353 | 381 | * @throws \Exception |
354 | 382 | */ |
355 | - private function saveVariants(array $data, float $product_cost_old, int $product_id, array $category_id, float $product_cost = NULL):array | |
383 | + private function saveVariants( | |
384 | + array $data, | |
385 | + float $product_cost_old, | |
386 | + int $product_id, | |
387 | + array $category_id, | |
388 | + float $product_cost = null | |
389 | + ):array | |
356 | 390 | { |
357 | 391 | $MOD_ARRAY = []; |
358 | - for($i = 13; $i < count($data); $i++) { | |
359 | - if(!empty ( $data[ $i ] )) { | |
392 | + for ($i = 13; $i < count($data); $i++) { | |
393 | + if (!empty ( $data[ $i ] )) { | |
360 | 394 | $mod_arr = explode('=', $data[ $i ]); |
361 | 395 | $mod_art = $mod_arr[ 0 ]; |
362 | 396 | $mod_art_parsed = $this->parseName($mod_art); |
363 | 397 | $variant_filters = explode('*', $mod_arr[ 1 ]); |
364 | 398 | $mod_name = $mod_arr[ 2 ]; |
365 | - if(empty( $mod_name )) { | |
399 | + if (empty( $mod_name )) { | |
366 | 400 | $mod_name = $mod_art_parsed[ 'name' ]; |
367 | 401 | } |
368 | 402 | $mod_image = $mod_arr[ 3 ]; |
... | ... | @@ -373,28 +407,35 @@ |
373 | 407 | /** |
374 | 408 | * @var ProductVariant $_productVariant |
375 | 409 | */ |
376 | - if(( $_productVariant = ProductVariant::find() | |
377 | - ->joinWith('lang') | |
378 | - ->andFilterWhere([ 'remote_id' => $mod_art_parsed[ 'remote_id' ] ]) | |
379 | - ->andFilterWhere([ 'product_variant.product_id' => $product_id ]) | |
380 | - ->one() ) === NULL | |
410 | + if (( $_productVariant = ProductVariant::find() | |
411 | + ->joinWith('lang') | |
412 | + ->andFilterWhere( | |
413 | + [ 'remote_id' => $mod_art_parsed[ 'remote_id' ] ] | |
414 | + ) | |
415 | + ->andFilterWhere( | |
416 | + [ 'product_variant.product_id' => $product_id ] | |
417 | + ) | |
418 | + ->one() ) === null | |
381 | 419 | ) { |
382 | 420 | $_productVariant = new ProductVariant(); |
383 | 421 | $_productVariant->product_id = $product_id; |
384 | - if(!empty( $mod_art_parsed[ 'remote_id' ] )) { | |
422 | + if (!empty( $mod_art_parsed[ 'remote_id' ] )) { | |
385 | 423 | $_productVariant->remote_id = $mod_art_parsed[ 'remote_id' ]; |
386 | 424 | } |
387 | 425 | $_productVariant->generateLangs(); |
388 | 426 | $product_variant_langs = $_productVariant->modelLangs; |
389 | - foreach($product_variant_langs as $product_variant_lang) { | |
427 | + foreach ($product_variant_langs as $product_variant_lang) { | |
390 | 428 | $product_variant_lang->title = $mod_name; |
391 | 429 | } |
392 | 430 | } else { |
393 | - if(!empty( $_productVariant->lang )) { | |
431 | + if (!empty( $_productVariant->lang )) { | |
394 | 432 | $_productVariant->lang->title = $mod_name; |
395 | 433 | $_productVariant->lang->save(false); |
396 | 434 | } else { |
397 | - throw new \Exception('Product variant with ID ' . $_productVariant->product_variant_id . ' and lang ' . Language::getCurrent()->id . ' doesn\'t exist'); | |
435 | + throw new \Exception( | |
436 | + 'Product variant with ID ' . $_productVariant->id . ' and lang ' . Language::getCurrent( | |
437 | + )->id . ' doesn\'t exist' | |
438 | + ); | |
398 | 439 | } |
399 | 440 | } |
400 | 441 | $_productVariant->product_unit_id = 1; |
... | ... | @@ -403,11 +444,11 @@ |
403 | 444 | $_productVariant->price_old = $mod_old_cost; |
404 | 445 | $_productVariant->stock = $mod_stock; |
405 | 446 | |
406 | - if(!empty ( $variant_filters )) { | |
447 | + if (!empty ( $variant_filters )) { | |
407 | 448 | $variants_options = $this->saveFilters($variant_filters, 1, $category_id); |
408 | 449 | } |
409 | 450 | |
410 | - if(isset( $variants_options ) && !empty( $variants_options )) { | |
451 | + if (isset( $variants_options ) && !empty( $variants_options )) { | |
411 | 452 | $_productVariant->options = $variants_options; |
412 | 453 | } |
413 | 454 | |
... | ... | @@ -416,8 +457,8 @@ |
416 | 457 | */ |
417 | 458 | $_productVariant->save(false); |
418 | 459 | |
419 | - $MOD_ARRAY[] = $_productVariant->product_variant_id; | |
420 | - $this->saveFotos([ $mod_image ], $product_id, $_productVariant->product_variant_id); | |
460 | + $MOD_ARRAY[] = $_productVariant->id; | |
461 | + $this->saveFotos([ $mod_image ], $product_id, $_productVariant->id); | |
421 | 462 | } |
422 | 463 | } |
423 | 464 | return $MOD_ARRAY; |
... | ... | @@ -427,45 +468,54 @@ |
427 | 468 | // echo $message.': '.(time()-$start_time).'s passed'; |
428 | 469 | // } |
429 | 470 | |
430 | - public function goProducts($from = 0, $limit = NULL) | |
471 | + public function goProducts($from = 0, $limit = null) | |
431 | 472 | { |
432 | 473 | set_time_limit(0); |
433 | 474 | |
434 | - if(!( $handle = $this->getProductsFile('uploadFileProducts') )) { | |
475 | + if (!( $handle = $this->getProductsFile('uploadFileProducts') )) { | |
435 | 476 | $this->errors[] = 'File not found'; |
436 | 477 | return false; |
437 | 478 | } |
438 | 479 | |
439 | 480 | $filesize = filesize(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFileProducts')); |
440 | 481 | |
441 | - if($from) { | |
482 | + if ($from) { | |
442 | 483 | fseek($handle, $from); |
443 | 484 | } |
444 | 485 | |
445 | 486 | $j = 0; |
446 | 487 | |
447 | - $is_utf = ( preg_match('//u', file_get_contents(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFileProducts'), NULL, NULL, NULL, 1000000)) ); | |
488 | + $is_utf = ( preg_match( | |
489 | + '//u', | |
490 | + file_get_contents( | |
491 | + Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFileProducts'), | |
492 | + null, | |
493 | + null, | |
494 | + null, | |
495 | + 1000000 | |
496 | + ) | |
497 | + ) ); | |
448 | 498 | |
449 | 499 | $result_items = []; |
450 | 500 | |
451 | - while(( empty( $limit ) || $j++ < $limit ) && ( $data = fgetcsv($handle, 10000, ";") ) !== false) { | |
501 | + while (( empty( $limit ) || $j++ < $limit ) && ( $data = fgetcsv($handle, 10000, ";") ) !== false) { | |
452 | 502 | try { |
453 | 503 | |
454 | - foreach($data as &$value) { | |
455 | - if(!$is_utf) { | |
504 | + foreach ($data as &$value) { | |
505 | + if (!$is_utf) { | |
456 | 506 | $value = iconv('windows-1251', "UTF-8//TRANSLIT//IGNORE", $value); |
457 | 507 | } |
458 | 508 | $value = trim($value); |
459 | 509 | } |
460 | 510 | // ะฑัะดะตั ะฒัะตะณะดะฐ 19 ัะปะตะผะตะฝัะพะฒ |
461 | - for($i = 0; $i <= 18; $i++) { | |
462 | - if(!isset ( $data[ $i ] )) { | |
463 | - $data[ $i ] = NULL; | |
511 | + for ($i = 0; $i <= 18; $i++) { | |
512 | + if (!isset ( $data[ $i ] )) { | |
513 | + $data[ $i ] = null; | |
464 | 514 | } |
465 | 515 | } |
466 | 516 | // 1 ะััะฟะฟะฐ (ะบะฐัะตะณะพัะธั) |
467 | 517 | $catalog_names = explode(',', $data[ 0 ]); |
468 | - if(empty ( $catalog_names )) { | |
518 | + if (empty ( $catalog_names )) { | |
469 | 519 | $result_items[] = "ะะต ัะบะฐะทะฐะฝะฐ ะบะฐัะตะณะพัะธั (ัััะพะบะฐ $j)"; |
470 | 520 | continue; |
471 | 521 | } |
... | ... | @@ -479,7 +529,7 @@ |
479 | 529 | |
480 | 530 | // 3 ะะฐะทะฒะฐะฝะธะต ัะพะฒะฐัะฐ |
481 | 531 | $product_name = $data[ 2 ]; |
482 | - if(empty ( $product_name )) { | |
532 | + if (empty ( $product_name )) { | |
483 | 533 | $result_items[] = "ะะต ัะบะฐะทะฐะฝะพ ะฝะฐะธะผะตะฝะพะฒะฐะฝะธะต ัะพะฒะฐัะฐ (ัััะพะบะฐ $j)"; |
484 | 534 | continue; |
485 | 535 | } |
... | ... | @@ -493,15 +543,15 @@ |
493 | 543 | // 11 ะฆะตะฝะฐ ะฐะบัะธั |
494 | 544 | $product_cost_old = floatval($data[ 6 ]); |
495 | 545 | |
496 | - $product_cost = NULL; | |
546 | + $product_cost = null; | |
497 | 547 | // 10 ะฆะตะฝะฐ |
498 | - if($product_cost_old) { | |
548 | + if ($product_cost_old) { | |
499 | 549 | $product_cost_old = floatval($data[ 5 ]); |
500 | 550 | $product_cost = floatval($data[ 6 ]); |
501 | 551 | } |
502 | 552 | |
503 | 553 | // 12 ะะบัะธั |
504 | - $product_akciya = (bool) $data[ 7 ]; | |
554 | + $product_discount = (bool) $data[ 7 ]; | |
505 | 555 | |
506 | 556 | // 13 ะกะพะฟัะด. ะขะพะฒ. |
507 | 557 | $similar = explode(',', $data[ 8 ]); |
... | ... | @@ -517,7 +567,7 @@ |
517 | 567 | |
518 | 568 | // 18 ะะฐะปะปะตัะตั ัะพัะพ |
519 | 569 | $fotos = []; |
520 | - if(trim($data[ 12 ])) { | |
570 | + if (trim($data[ 12 ])) { | |
521 | 571 | $fotos = explode(',', trim($data[ 12 ])); |
522 | 572 | } |
523 | 573 | |
... | ... | @@ -534,30 +584,35 @@ |
534 | 584 | $brand_id = $this->saveBrand($brand_name); |
535 | 585 | |
536 | 586 | $options = []; |
537 | - if(!empty ( $filters )) { | |
587 | + if (!empty ( $filters )) { | |
538 | 588 | $options = $this->saveFilters($filters, 0, $categories); |
539 | 589 | } |
540 | 590 | $parsed_name = $this->parseName($product_name); |
541 | 591 | /** |
542 | 592 | * @var Product $_product |
543 | 593 | */ |
544 | - if(!empty( $parsed_name[ 'remote_id' ] ) && ( $_product = Product::find() | |
545 | - ->joinWith('lang') | |
546 | - ->andFilterWhere([ 'remote_id' => $parsed_name[ 'remote_id' ] ]) | |
547 | - ->one() ) !== NULL | |
594 | + if (!empty( $parsed_name[ 'remote_id' ] ) && ( $_product = Product::find() | |
595 | + ->joinWith('lang') | |
596 | + ->andFilterWhere( | |
597 | + [ 'remote_id' => $parsed_name[ 'remote_id' ] ] | |
598 | + ) | |
599 | + ->one() ) !== null | |
548 | 600 | ) { |
549 | - if(!empty( $_product->lang )) { | |
601 | + if (!empty( $_product->lang )) { | |
550 | 602 | $_product->lang->title = $parsed_name[ 'name' ]; |
551 | 603 | $_product->lang->description = $product_body; |
552 | 604 | $_product->lang->save(false); |
553 | 605 | } else { |
554 | - throw new \Exception('Product with ID ' . $_product->id . ' and lang ' . Language::getCurrent()->id . ' doesn\'t exist'); | |
606 | + throw new \Exception( | |
607 | + 'Product with ID ' . $_product->id . ' and lang ' . Language::getCurrent( | |
608 | + )->id . ' doesn\'t exist' | |
609 | + ); | |
555 | 610 | } |
556 | 611 | } else { |
557 | 612 | $_product = new Product(); |
558 | 613 | $_product->generateLangs(); |
559 | 614 | $product_langs = $_product->modelLangs; |
560 | - foreach($product_langs as $product_lang) { | |
615 | + foreach ($product_langs as $product_lang) { | |
561 | 616 | $product_lang->title = $parsed_name[ 'name' ]; |
562 | 617 | $product_lang->description = $product_body; |
563 | 618 | } |
... | ... | @@ -571,19 +626,19 @@ |
571 | 626 | |
572 | 627 | $_product->video = $product_video; |
573 | 628 | $_product->is_top = $product_top; |
574 | - $_product->akciya = $product_akciya; | |
629 | + $_product->is_discount = $product_discount; | |
575 | 630 | $_product->is_new = $product_new; |
576 | - if(!empty( $options )) { | |
631 | + if (!empty( $options )) { | |
577 | 632 | $_product->options = $options; |
578 | 633 | } |
579 | 634 | |
580 | - if(!empty( $_product->lang )) { | |
635 | + if (!empty( $_product->lang )) { | |
581 | 636 | $product_name_inserted = $_product->lang->title; |
582 | 637 | } else { |
583 | 638 | $product_name_inserted = $_product->modelLangs[ Language::$current->id ]->title; |
584 | 639 | } |
585 | 640 | |
586 | - if(( $_product->save(false) === false ) || !$_product->transactionStatus) { | |
641 | + if (( $_product->save(false) === false ) || !$_product->transactionStatus) { | |
587 | 642 | $result_items[] = 'Product #' . $product_name_inserted . ' not saved' . " (line $j)"; |
588 | 643 | continue; |
589 | 644 | } |
... | ... | @@ -597,7 +652,7 @@ |
597 | 652 | |
598 | 653 | $result_items[] = "Product {$product_name_inserted} #{$_product->id} saved (" . ( $is_new_product ? 'new product' : 'exists product' ) . ")" . " (line $j)"; |
599 | 654 | |
600 | - } catch(\Exception $e) { | |
655 | + } catch (\Exception $e) { | |
601 | 656 | $result_items[] = $e->getMessage() . '(line ' . $j . ')'; |
602 | 657 | } |
603 | 658 | |
... | ... | @@ -612,7 +667,7 @@ |
612 | 667 | |
613 | 668 | fclose($handle); |
614 | 669 | |
615 | - if($result[ 'end' ]) { | |
670 | + if ($result[ 'end' ]) { | |
616 | 671 | // unlink(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFileProducts')); |
617 | 672 | } |
618 | 673 | |
... | ... | @@ -622,7 +677,7 @@ |
622 | 677 | private function getProductsFile($file_type) |
623 | 678 | { |
624 | 679 | $filename = Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@' . $file_type); |
625 | - if(!is_file($filename)) { | |
680 | + if (!is_file($filename)) { | |
626 | 681 | $this->errors[] = "File $filename not found"; |
627 | 682 | return false; |
628 | 683 | } |
... | ... | @@ -642,11 +697,11 @@ |
642 | 697 | private function saveFilters(array $filters, int $level, array $catalog_names):array |
643 | 698 | { |
644 | 699 | $options = []; |
645 | - foreach($filters as $filter) { | |
700 | + foreach ($filters as $filter) { | |
646 | 701 | |
647 | 702 | preg_match_all('/\[(.*):(.*)\]/', $filter, $filter); |
648 | 703 | |
649 | - if(empty( $filter[ 1 ][ 0 ] )) { | |
704 | + if (empty( $filter[ 1 ][ 0 ] )) { | |
650 | 705 | continue; |
651 | 706 | } |
652 | 707 | $filter_name = trim($filter[ 1 ][ 0 ]); |
... | ... | @@ -655,22 +710,27 @@ |
655 | 710 | /** |
656 | 711 | * @var TaxGroup $taxGroup |
657 | 712 | */ |
658 | - if(!empty( $parsed_group_name[ 'remote_id' ] ) && ( $taxGroup = TaxGroup::find() | |
659 | - ->joinWith('lang') | |
660 | - ->andFilterWhere([ 'remote_id' => $parsed_group_name[ 'remote_id' ] ]) | |
661 | - ->one() ) !== NULL | |
713 | + if (!empty( $parsed_group_name[ 'remote_id' ] ) && ( $taxGroup = TaxGroup::find() | |
714 | + ->joinWith('lang') | |
715 | + ->andFilterWhere( | |
716 | + [ 'remote_id' => $parsed_group_name[ 'remote_id' ] ] | |
717 | + ) | |
718 | + ->one() ) !== null | |
662 | 719 | ) { |
663 | - if(!empty( $taxGroup->lang )) { | |
720 | + if (!empty( $taxGroup->lang )) { | |
664 | 721 | $taxGroup->lang->title = $parsed_group_name[ 'name' ]; |
665 | 722 | $taxGroup->lang->save(false); |
666 | 723 | } else { |
667 | - throw new \Exception('Tax group with ID ' . $taxGroup->tax_group_id . ' and lang ' . Language::getCurrent()->id . ' doesn\'t exist'); | |
724 | + throw new \Exception( | |
725 | + 'Tax group with ID ' . $taxGroup->tax_group_id . ' and lang ' . Language::getCurrent( | |
726 | + )->id . ' doesn\'t exist' | |
727 | + ); | |
668 | 728 | } |
669 | 729 | } else { |
670 | 730 | $taxGroup = new TaxGroup(); |
671 | 731 | $taxGroup->generateLangs(); |
672 | 732 | $tax_group_langs = $taxGroup->modelLangs; |
673 | - foreach($tax_group_langs as $tax_group_lang) { | |
733 | + foreach ($tax_group_langs as $tax_group_lang) { | |
674 | 734 | $tax_group_lang->title = $parsed_group_name[ 'name' ]; |
675 | 735 | } |
676 | 736 | $taxGroup->level = $level; |
... | ... | @@ -679,30 +739,37 @@ |
679 | 739 | $taxGroup->save(false); |
680 | 740 | } |
681 | 741 | $filters_options = explode(',', $filter[ 2 ][ 0 ]); |
682 | - foreach($filters_options as $filter_options) { | |
742 | + foreach ($filters_options as $filter_options) { | |
683 | 743 | $parsed_option_name = $this->parseName($filter_options); |
684 | 744 | /** |
685 | 745 | * @var TaxOption $option |
686 | 746 | */ |
687 | 747 | |
688 | - if(!empty( $parsed_option_name[ 'remote_id' ] ) && ( $option = TaxOption::find() | |
689 | - ->joinWith('lang') | |
690 | - ->andFilterWhere([ 'remote_id' => $parsed_option_name[ 'remote_id' ] ]) | |
691 | - ->andFilterWhere([ 'tax_group_id' => $taxGroup->tax_group_id ]) | |
692 | - ->one() ) !== NULL | |
748 | + if (!empty( $parsed_option_name[ 'remote_id' ] ) && ( $option = TaxOption::find() | |
749 | + ->joinWith('lang') | |
750 | + ->andFilterWhere( | |
751 | + [ 'remote_id' => $parsed_option_name[ 'remote_id' ] ] | |
752 | + ) | |
753 | + ->andFilterWhere( | |
754 | + [ 'tax_group_id' => $taxGroup->tax_group_id ] | |
755 | + ) | |
756 | + ->one() ) !== null | |
693 | 757 | ) { |
694 | - if(!empty( $option->lang )) { | |
758 | + if (!empty( $option->lang )) { | |
695 | 759 | $option->lang->value = $parsed_option_name[ 'name' ]; |
696 | 760 | $option->lang->save(false); |
697 | 761 | } else { |
698 | - throw new \Exception('Tax option with ID ' . $option->tax_option_id . ' and lang ' . Language::getCurrent()->id . ' doesn\'t exist'); | |
762 | + throw new \Exception( | |
763 | + 'Tax option with ID ' . $option->tax_option_id . ' and lang ' . Language::getCurrent( | |
764 | + )->id . ' doesn\'t exist' | |
765 | + ); | |
699 | 766 | } |
700 | 767 | } else { |
701 | 768 | // Create option |
702 | 769 | $option = new TaxOption(); |
703 | 770 | $option->generateLangs(); |
704 | 771 | $option_langs = $option->modelLangs; |
705 | - foreach($option_langs as $option_lang) { | |
772 | + foreach ($option_langs as $option_lang) { | |
706 | 773 | $option_lang->value = $parsed_option_name[ 'name' ]; |
707 | 774 | } |
708 | 775 | $option->tax_group_id = $taxGroup->tax_group_id; | ... | ... |
common/modules/product/models/Product.php
... | ... | @@ -18,6 +18,7 @@ |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * This is the model class for table "{{%product}}". |
21 | + * | |
21 | 22 | * @property integer $brand_id |
22 | 23 | * @property integer $id |
23 | 24 | * @property Category $category |
... | ... | @@ -26,7 +27,7 @@ |
26 | 27 | * @property ProductVariant $variant |
27 | 28 | * @property boolean $is_top |
28 | 29 | * @property boolean $is_new |
29 | - * @property boolean $akciya | |
30 | + * @property boolean $is_discount | |
30 | 31 | * @property ProductToRating $averageRating |
31 | 32 | * @property array $properties |
32 | 33 | * @property ProductVariant $enabledVariant |
... | ... | @@ -98,7 +99,7 @@ |
98 | 99 | 'id' => 'product_id', |
99 | 100 | ], |
100 | 101 | 'conditions' => [ |
101 | - 'product_variant_id' => NULL, | |
102 | + 'product_variant_id' => null, | |
102 | 103 | ], |
103 | 104 | 'model' => ProductImage::className(), |
104 | 105 | 'config' => [ |
... | ... | @@ -153,7 +154,7 @@ |
153 | 154 | [ |
154 | 155 | 'is_top', |
155 | 156 | 'is_new', |
156 | - 'akciya', | |
157 | + 'is_discount', | |
157 | 158 | ], |
158 | 159 | 'boolean', |
159 | 160 | ], |
... | ... | @@ -166,19 +167,19 @@ |
166 | 167 | public function attributeLabels() |
167 | 168 | { |
168 | 169 | return [ |
169 | - 'id' => Yii::t('product', 'ID'), | |
170 | - 'brand_id' => Yii::t('product', 'Brand'), | |
171 | - 'categories' => Yii::t('product', 'Categories'), | |
170 | + 'id' => Yii::t('product', 'ID'), | |
171 | + 'brand_id' => Yii::t('product', 'Brand'), | |
172 | + 'categories' => Yii::t('product', 'Categories'), | |
172 | 173 | // relation behavior field |
173 | - 'category' => Yii::t('product', 'Category'), | |
174 | + 'category' => Yii::t('product', 'Category'), | |
174 | 175 | // relation behavior field |
175 | - 'image' => Yii::t('product', 'Image'), | |
176 | - 'images' => Yii::t('product', 'Images'), | |
177 | - 'video' => Yii::t('product', 'Video embeded'), | |
178 | - 'variants' => Yii::t('product', 'Variants'), | |
179 | - 'is_top' => Yii::t('product', 'Is top'), | |
180 | - 'is_new' => Yii::t('product', 'Is new'), | |
181 | - 'akciya' => Yii::t('product', 'Is promo'), | |
176 | + 'image' => Yii::t('product', 'Image'), | |
177 | + 'images' => Yii::t('product', 'Images'), | |
178 | + 'video' => Yii::t('product', 'Video embeded'), | |
179 | + 'variants' => Yii::t('product', 'Variants'), | |
180 | + 'is_top' => Yii::t('product', 'Is top'), | |
181 | + 'is_new' => Yii::t('product', 'Is new'), | |
182 | + 'is_discount' => Yii::t('product', 'Is promo'), | |
182 | 183 | ]; |
183 | 184 | } |
184 | 185 | |
... | ... | @@ -204,11 +205,13 @@ |
204 | 205 | public function getEnabledVariant() |
205 | 206 | { |
206 | 207 | return $this->hasOne(ProductVariant::className(), [ 'product_id' => 'id' ]) |
207 | - ->andOnCondition([ | |
208 | - '!=', | |
209 | - ProductVariant::tableName() . '.stock', | |
210 | - 0, | |
211 | - ]); | |
208 | + ->andOnCondition( | |
209 | + [ | |
210 | + '!=', | |
211 | + ProductVariant::tableName() . '.stock', | |
212 | + 0, | |
213 | + ] | |
214 | + ); | |
212 | 215 | } |
213 | 216 | |
214 | 217 | public function getVariantPrice() |
... | ... | @@ -232,11 +235,13 @@ |
232 | 235 | public function getEnabledVariants() |
233 | 236 | { |
234 | 237 | return $this->hasMany(ProductVariant::className(), [ 'product_id' => 'id' ]) |
235 | - ->andOnCondition([ | |
236 | - '!=', | |
237 | - ProductVariant::tableName() . '.stock', | |
238 | - 0, | |
239 | - ]) | |
238 | + ->andOnCondition( | |
239 | + [ | |
240 | + '!=', | |
241 | + ProductVariant::tableName() . '.stock', | |
242 | + 0, | |
243 | + ] | |
244 | + ) | |
240 | 245 | ->joinWith('image'); |
241 | 246 | } |
242 | 247 | |
... | ... | @@ -262,7 +267,7 @@ |
262 | 267 | public function getCategoriesNames() |
263 | 268 | { |
264 | 269 | $result = []; |
265 | - foreach($this->categories as $category) { | |
270 | + foreach ($this->categories as $category) { | |
266 | 271 | $result[] = $category->lang->title; |
267 | 272 | } |
268 | 273 | return $result; |
... | ... | @@ -272,10 +277,12 @@ |
272 | 277 | { |
273 | 278 | return $this->hasMany(ProductVariant::className(), [ 'product_id' => 'id' ]) |
274 | 279 | ->joinWith('lang', true, 'INNER JOIN') |
275 | - ->with([ | |
276 | - 'filters', | |
277 | - 'image', | |
278 | - ]); | |
280 | + ->with( | |
281 | + [ | |
282 | + 'filters', | |
283 | + 'image', | |
284 | + ] | |
285 | + ); | |
279 | 286 | } |
280 | 287 | |
281 | 288 | /** |
... | ... | @@ -299,16 +306,16 @@ |
299 | 306 | public function getProperties() |
300 | 307 | { |
301 | 308 | $groups = $options = []; |
302 | - foreach($this->getOptions() | |
303 | - ->with('lang') | |
304 | - ->all() as $option) { | |
309 | + foreach ($this->getOptions() | |
310 | + ->with('lang') | |
311 | + ->all() as $option) { | |
305 | 312 | $options[ $option->tax_group_id ][] = $option; |
306 | 313 | } |
307 | - foreach(TaxGroup::find() | |
308 | - ->where([ 'tax_group_id' => array_keys($options) ]) | |
309 | - ->with('lang') | |
310 | - ->all() as $group) { | |
311 | - if(!empty( $options[ $group->tax_group_id ] )) { | |
314 | + foreach (TaxGroup::find() | |
315 | + ->where([ 'tax_group_id' => array_keys($options) ]) | |
316 | + ->with('lang') | |
317 | + ->all() as $group) { | |
318 | + if (!empty( $options[ $group->tax_group_id ] )) { | |
312 | 319 | $group->options = $options[ $group->tax_group_id ]; |
313 | 320 | $groups[] = $group; |
314 | 321 | } |
... | ... | @@ -319,21 +326,23 @@ |
319 | 326 | public function getActiveProperties($category_id) |
320 | 327 | { |
321 | 328 | $groups = $options = []; |
322 | - foreach($this->options as $option) { | |
329 | + foreach ($this->options as $option) { | |
323 | 330 | $options[ $option->tax_group_id ][] = $option; |
324 | 331 | } |
325 | 332 | |
326 | 333 | $taxGroups = TaxGroup::find() |
327 | 334 | ->joinWith('categories') |
328 | - ->where([ | |
329 | - 'tax_group.tax_group_id' => array_keys($options), | |
330 | - 'tax_group.display' => true, | |
331 | - 'category.id' => $category_id, | |
332 | - ]) | |
335 | + ->where( | |
336 | + [ | |
337 | + 'tax_group.tax_group_id' => array_keys($options), | |
338 | + 'tax_group.display' => true, | |
339 | + 'category.id' => $category_id, | |
340 | + ] | |
341 | + ) | |
333 | 342 | ->all(); |
334 | 343 | |
335 | - foreach($taxGroups as $group) { | |
336 | - if(!empty( $options[ $group->tax_group_id ] )) { | |
344 | + foreach ($taxGroups as $group) { | |
345 | + if (!empty( $options[ $group->tax_group_id ] )) { | |
337 | 346 | $group->options = $options[ $group->tax_group_id ]; |
338 | 347 | $groups[] = $group; |
339 | 348 | } |
... | ... | @@ -343,8 +352,8 @@ |
343 | 352 | |
344 | 353 | public function getStocks() |
345 | 354 | { |
346 | - return $this->hasMany(Stock::className(), [ 'stock_id' => 'stock_id' ]) | |
347 | - ->viaTable(ProductStock::tableName(), [ 'product_id' => 'id' ]); | |
355 | + return $this->hasMany(Stock::className(), [ 'id' => 'product_id' ]) | |
356 | + ->via('variants'); | |
348 | 357 | } |
349 | 358 | |
350 | 359 | public function getQuantity() |
... | ... | @@ -358,34 +367,37 @@ |
358 | 367 | { |
359 | 368 | parent::afterSave($insert, $changedAttributes); |
360 | 369 | |
361 | - if(!empty( $this->categories )) { | |
370 | + if (!empty( $this->categories )) { | |
362 | 371 | $categories = Category::findAll($this->categories); |
363 | 372 | $this->unlinkAll('categories', true); |
364 | - foreach($categories as $category) { | |
373 | + foreach ($categories as $category) { | |
365 | 374 | $this->link('categories', $category); |
366 | 375 | } |
367 | 376 | } |
368 | 377 | |
369 | - if(!empty( $this->options )) { | |
378 | + if (!empty( $this->options )) { | |
370 | 379 | $options = TaxOption::findAll($this->options); |
371 | 380 | $this->unlinkAll('options', true); |
372 | - foreach($options as $option) { | |
381 | + foreach ($options as $option) { | |
373 | 382 | $this->link('options', $option); |
374 | 383 | } |
375 | 384 | } |
376 | 385 | |
377 | - if(!empty( $this->variants )) { | |
386 | + if (!empty( $this->variants )) { | |
378 | 387 | $todel = []; |
379 | - foreach($this->variants ? : [] as $_variant) { | |
380 | - $todel[ $_variant->product_variant_id ] = $_variant->product_variant_id; | |
388 | + foreach ($this->variants ? : [] as $_variant) { | |
389 | + /** | |
390 | + * @var ProductVariant $_variant | |
391 | + */ | |
392 | + $todel[ $_variant->id ] = $_variant->id; | |
381 | 393 | } |
382 | - foreach($this->variants as $_variant) { | |
383 | - if(!is_array($_variant)) { | |
394 | + foreach ($this->variants as $_variant) { | |
395 | + if (!is_array($_variant)) { | |
384 | 396 | return; |
385 | 397 | } |
386 | - if(!empty( $_variant[ 'product_variant_id' ] )) { | |
387 | - unset( $todel[ $_variant[ 'product_variant_id' ] ] ); | |
388 | - $model = ProductVariant::findOne($_variant[ 'product_variant_id' ]); | |
398 | + if (!empty( $_variant[ 'id' ] )) { | |
399 | + unset( $todel[ $_variant[ 'id' ] ] ); | |
400 | + $model = ProductVariant::findOne($_variant[ 'id' ]); | |
389 | 401 | } else { |
390 | 402 | $model = new ProductVariant(); |
391 | 403 | } |
... | ... | @@ -394,8 +406,8 @@ |
394 | 406 | $model->product_id = $this->id; |
395 | 407 | $model->save(); |
396 | 408 | } |
397 | - if(!empty( $todel )) { | |
398 | - ProductVariant::deleteAll([ 'product_variant_id' => $todel ]); | |
409 | + if (!empty( $todel )) { | |
410 | + ProductVariant::deleteAll([ 'id' => $todel ]); | |
399 | 411 | } |
400 | 412 | } |
401 | 413 | } |
... | ... | @@ -409,19 +421,21 @@ |
409 | 421 | ->joinWith('rating') |
410 | 422 | ->select([ 'average' => 'avg(artbox_comment_rating.value)::float' ]) |
411 | 423 | ->scalar(); |
412 | - if(!$average) { | |
424 | + if (!$average) { | |
413 | 425 | $average = 0; |
414 | 426 | } |
415 | 427 | $averageRating = $this->averageRating; |
416 | - if(!empty( $averageRating )) { | |
428 | + if (!empty( $averageRating )) { | |
417 | 429 | $averageRating->value = $average; |
418 | 430 | } else { |
419 | - $averageRating = new ProductToRating([ | |
420 | - 'product_id' => $this->id, | |
421 | - 'value' => $average, | |
422 | - ]); | |
431 | + $averageRating = new ProductToRating( | |
432 | + [ | |
433 | + 'product_id' => $this->id, | |
434 | + 'value' => $average, | |
435 | + ] | |
436 | + ); | |
423 | 437 | } |
424 | - if($averageRating->save()) { | |
438 | + if ($averageRating->save()) { | |
425 | 439 | return true; |
426 | 440 | } else { |
427 | 441 | return false; |
... | ... | @@ -431,11 +445,13 @@ |
431 | 445 | public function getComments() |
432 | 446 | { |
433 | 447 | return $this->hasMany(CommentModel::className(), [ 'entity_id' => 'id' ]) |
434 | - ->where([ | |
435 | - 'artbox_comment.entity' => self::className(), | |
436 | - 'artbox_comment.status' => CommentModel::STATUS_ACTIVE, | |
437 | - 'artbox_comment.artbox_comment_pid' => NULL, | |
438 | - ]); | |
448 | + ->where( | |
449 | + [ | |
450 | + 'artbox_comment.entity' => self::className(), | |
451 | + 'artbox_comment.status' => CommentModel::STATUS_ACTIVE, | |
452 | + 'artbox_comment.artbox_comment_pid' => null, | |
453 | + ] | |
454 | + ); | |
439 | 455 | } |
440 | 456 | |
441 | 457 | public function getAverageRating() |
... | ... | @@ -448,7 +464,10 @@ |
448 | 464 | $categories = ArrayHelper::getColumn($this->categories, 'id'); |
449 | 465 | return TaxGroup::find() |
450 | 466 | ->distinct() |
451 | - ->innerJoin('tax_group_to_category', 'tax_group_to_category.tax_group_id = tax_group.tax_group_id') | |
467 | + ->innerJoin( | |
468 | + 'tax_group_to_category', | |
469 | + 'tax_group_to_category.tax_group_id = tax_group.tax_group_id' | |
470 | + ) | |
452 | 471 | ->andWhere([ 'tax_group_to_category.category_id' => $categories ]) |
453 | 472 | ->andWhere([ 'level' => $level ]); |
454 | 473 | } | ... | ... |
common/modules/product/models/ProductImage.php
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This is the model class for table "product_image". |
11 | + * | |
11 | 12 | * @property integer $product_image_id |
12 | 13 | * @property integer $product_id |
13 | 14 | * @property integer $product_variant_id |
... | ... | @@ -78,7 +79,7 @@ |
78 | 79 | 'exist', |
79 | 80 | 'skipOnError' => true, |
80 | 81 | 'targetClass' => ProductVariant::className(), |
81 | - 'targetAttribute' => [ 'product_variant_id' => 'product_variant_id' ], | |
82 | + 'targetAttribute' => [ 'product_variant_id' => 'id' ], | |
82 | 83 | ], |
83 | 84 | ]; |
84 | 85 | } |
... | ... | @@ -106,7 +107,7 @@ |
106 | 107 | public function getProduct() |
107 | 108 | { |
108 | 109 | $return = $this->hasOne(Product::className(), [ 'id' => 'product_id' ]); |
109 | - if(empty( $return )) { | |
110 | + if (empty( $return )) { | |
110 | 111 | $return = $this->productVariant->product_id; |
111 | 112 | } |
112 | 113 | return $return; |
... | ... | @@ -117,6 +118,6 @@ |
117 | 118 | */ |
118 | 119 | public function getProductVariant() |
119 | 120 | { |
120 | - return $this->hasOne(Product::className(), [ 'product_variant_id' => 'product_variant_id' ]); | |
121 | + return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]); | |
121 | 122 | } |
122 | 123 | } | ... | ... |
common/modules/product/models/ProductSearch.php
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | public function behaviors() |
23 | 23 | { |
24 | 24 | $behaviors = parent::behaviors(); |
25 | - if(isset( $behaviors[ 'language' ] )) { | |
25 | + if (isset( $behaviors[ 'language' ] )) { | |
26 | 26 | unset( $behaviors[ 'language' ] ); |
27 | 27 | } |
28 | 28 | return $behaviors; |
... | ... | @@ -52,7 +52,7 @@ |
52 | 52 | [ |
53 | 53 | 'is_top', |
54 | 54 | 'is_new', |
55 | - 'akciya', | |
55 | + 'is_discount', | |
56 | 56 | ], |
57 | 57 | 'boolean', |
58 | 58 | ], |
... | ... | @@ -64,7 +64,7 @@ |
64 | 64 | $labels = parent::attributeLabels(); |
65 | 65 | $new_labels = [ |
66 | 66 | 'categoryId' => 'Category ID', |
67 | - 'brand_id' => 'Brand ID', | |
67 | + 'brand_id' => 'Brand ID', | |
68 | 68 | 'productName' => 'Product name', |
69 | 69 | 'variantCount' => 'Variant count', |
70 | 70 | ]; |
... | ... | @@ -91,79 +91,101 @@ |
91 | 91 | { |
92 | 92 | |
93 | 93 | $query = Product::find(); |
94 | - $query->select([ | |
95 | - 'product.*', | |
96 | - 'COUNT(product_variant.product_variant_id) as count', | |
97 | - ]); | |
94 | + $query->select( | |
95 | + [ | |
96 | + 'product.*', | |
97 | + 'COUNT(product_variant.id) as count', | |
98 | + ] | |
99 | + ); | |
98 | 100 | |
99 | - $query->joinWith([ | |
100 | - 'categories', | |
101 | - 'lang', | |
102 | - ]) | |
103 | - ->joinWith([ | |
104 | - 'brand' => function($query) { | |
105 | - /** | |
106 | - * @var ActiveQuery $query | |
107 | - */ | |
108 | - $query->joinWith('lang'); | |
109 | - }, | |
110 | - ]) | |
101 | + $query->joinWith( | |
102 | + [ | |
103 | + 'categories', | |
104 | + 'lang', | |
105 | + ] | |
106 | + ) | |
107 | + ->joinWith( | |
108 | + [ | |
109 | + 'brand' => function ($query) { | |
110 | + /** | |
111 | + * @var ActiveQuery $query | |
112 | + */ | |
113 | + $query->joinWith('lang'); | |
114 | + }, | |
115 | + ] | |
116 | + ) | |
111 | 117 | ->joinWith('variants'); |
112 | 118 | |
113 | - $query->groupBy([ | |
114 | - 'product.id', | |
115 | - 'brand_lang.title', | |
116 | - 'product_lang.title', | |
117 | - ]); | |
119 | + $query->groupBy( | |
120 | + [ | |
121 | + 'product.id', | |
122 | + 'brand_lang.title', | |
123 | + 'product_lang.title', | |
124 | + ] | |
125 | + ); | |
118 | 126 | |
119 | - $dataProvider = new ActiveDataProvider([ | |
120 | - 'query' => $query, | |
121 | - ]); | |
127 | + $dataProvider = new ActiveDataProvider( | |
128 | + [ | |
129 | + 'query' => $query, | |
130 | + ] | |
131 | + ); | |
122 | 132 | |
123 | - $dataProvider->setSort([ | |
124 | - 'attributes' => [ | |
125 | - 'id', | |
126 | - 'productName' => [ | |
127 | - 'asc' => [ 'product_lang.title' => SORT_ASC ], | |
128 | - 'desc' => [ 'product_lang.title' => SORT_DESC ], | |
129 | - ], | |
130 | - 'brand_id' => [ | |
131 | - 'asc' => [ 'brand_lang.title' => SORT_ASC ], | |
132 | - 'desc' => [ 'brand_lang.title' => SORT_DESC ], | |
133 | - 'default' => SORT_DESC, | |
134 | - ], | |
135 | - 'variantCount' => [ | |
136 | - 'asc' => [ 'count' => SORT_ASC ], | |
137 | - 'desc' => [ 'count' => SORT_DESC ], | |
133 | + $dataProvider->setSort( | |
134 | + [ | |
135 | + 'attributes' => [ | |
136 | + 'id', | |
137 | + 'productName' => [ | |
138 | + 'asc' => [ 'product_lang.title' => SORT_ASC ], | |
139 | + 'desc' => [ 'product_lang.title' => SORT_DESC ], | |
140 | + ], | |
141 | + 'brand_id' => [ | |
142 | + 'asc' => [ 'brand_lang.title' => SORT_ASC ], | |
143 | + 'desc' => [ 'brand_lang.title' => SORT_DESC ], | |
144 | + 'default' => SORT_DESC, | |
145 | + ], | |
146 | + 'variantCount' => [ | |
147 | + 'asc' => [ 'count' => SORT_ASC ], | |
148 | + 'desc' => [ 'count' => SORT_DESC ], | |
149 | + ], | |
138 | 150 | ], |
139 | - ], | |
140 | - ]); | |
151 | + ] | |
152 | + ); | |
141 | 153 | |
142 | - if(isset( $this->is_top )) { | |
143 | - $query->andWhere([ | |
144 | - 'is_top' => (bool) $this->is_top, | |
145 | - ]); | |
154 | + if (isset( $this->is_top )) { | |
155 | + $query->andWhere( | |
156 | + [ | |
157 | + 'is_top' => (bool) $this->is_top, | |
158 | + ] | |
159 | + ); | |
146 | 160 | } |
147 | - if(isset( $this->is_new )) { | |
148 | - $query->andWhere([ | |
149 | - 'is_new' => (bool) $this->is_new, | |
150 | - ]); | |
161 | + if (isset( $this->is_new )) { | |
162 | + $query->andWhere( | |
163 | + [ | |
164 | + 'is_new' => (bool) $this->is_new, | |
165 | + ] | |
166 | + ); | |
151 | 167 | } |
152 | - if(isset( $this->akciya )) { | |
153 | - $query->andWhere([ | |
154 | - 'akciya' => (bool) $this->akciya, | |
155 | - ]); | |
168 | + if (isset( $this->is_discount )) { | |
169 | + $query->andWhere( | |
170 | + [ | |
171 | + 'is_discount' => (bool) $this->is_discount, | |
172 | + ] | |
173 | + ); | |
156 | 174 | } |
157 | - $query->andFilterWhere([ | |
158 | - 'product.brand_id' => $this->brand_id, | |
159 | - 'product.id' => $this->id, | |
160 | - 'product_category.category_id' => $this->categoryId, | |
161 | - ]); | |
162 | - $query->andFilterWhere([ | |
163 | - 'like', | |
164 | - 'product_lang.title', | |
165 | - $this->productName, | |
166 | - ]); | |
175 | + $query->andFilterWhere( | |
176 | + [ | |
177 | + 'product.brand_id' => $this->brand_id, | |
178 | + 'product.id' => $this->id, | |
179 | + 'product_category.category_id' => $this->categoryId, | |
180 | + ] | |
181 | + ); | |
182 | + $query->andFilterWhere( | |
183 | + [ | |
184 | + 'like', | |
185 | + 'product_lang.title', | |
186 | + $this->productName, | |
187 | + ] | |
188 | + ); | |
167 | 189 | |
168 | 190 | return $dataProvider; |
169 | 191 | } | ... | ... |
common/modules/product/models/ProductStock.php
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | |
7 | 7 | /** |
8 | 8 | * This is the model class for table "product_stock". |
9 | - * @property integer $product_id | |
9 | + * | |
10 | 10 | * @property integer $stock_id |
11 | 11 | * @property integer $quantity |
12 | 12 | * @property integer $product_variant_id |
... | ... | @@ -33,7 +33,6 @@ |
33 | 33 | return [ |
34 | 34 | [ |
35 | 35 | [ |
36 | - 'product_id', | |
37 | 36 | 'stock_id', |
38 | 37 | 'quantity', |
39 | 38 | 'product_variant_id', |
... | ... | @@ -45,25 +44,18 @@ |
45 | 44 | 'required', |
46 | 45 | ], |
47 | 46 | [ |
48 | - [ 'product_id' ], | |
49 | - 'exist', | |
50 | - 'skipOnError' => true, | |
51 | - 'targetClass' => Product::className(), | |
52 | - 'targetAttribute' => [ 'product_id' => 'id' ], | |
53 | - ], | |
54 | - [ | |
55 | 47 | [ 'product_variant_id' ], |
56 | 48 | 'exist', |
57 | 49 | 'skipOnError' => true, |
58 | 50 | 'targetClass' => ProductVariant::className(), |
59 | - 'targetAttribute' => [ 'product_variant_id' => 'product_variant_id' ], | |
51 | + 'targetAttribute' => [ 'product_variant_id' => 'id' ], | |
60 | 52 | ], |
61 | 53 | [ |
62 | 54 | [ 'stock_id' ], |
63 | 55 | 'exist', |
64 | 56 | 'skipOnError' => true, |
65 | 57 | 'targetClass' => Stock::className(), |
66 | - 'targetAttribute' => [ 'stock_id' => 'stock_id' ], | |
58 | + 'targetAttribute' => [ 'stock_id' => 'id' ], | |
67 | 59 | ], |
68 | 60 | ]; |
69 | 61 | } |
... | ... | @@ -74,11 +66,10 @@ |
74 | 66 | public function attributeLabels() |
75 | 67 | { |
76 | 68 | return [ |
77 | - 'product_id' => 'Product ID', | |
78 | 69 | 'stock_id' => 'Stock ID', |
79 | 70 | 'quantity' => 'ะะพะปะธัะตััะฒะพ', |
80 | 71 | 'product_variant_id' => 'Product Variant ID', |
81 | - 'title' => "ะะฐะทะฒะฐะฝะธะต", | |
72 | + 'title' => "ะะฐะทะฒะฐะฝะธะต", | |
82 | 73 | ]; |
83 | 74 | } |
84 | 75 | |
... | ... | @@ -87,7 +78,8 @@ |
87 | 78 | */ |
88 | 79 | public function getProduct() |
89 | 80 | { |
90 | - return $this->hasOne(Product::className(), [ 'id' => 'product_id' ]); | |
81 | + return $this->hasOne(Product::className(), [ 'id' => 'product_id' ]) | |
82 | + ->via('variants'); | |
91 | 83 | } |
92 | 84 | |
93 | 85 | /** |
... | ... | @@ -95,14 +87,14 @@ |
95 | 87 | */ |
96 | 88 | public function getProductVariant() |
97 | 89 | { |
98 | - return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ]); | |
90 | + return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]); | |
99 | 91 | } |
100 | 92 | |
101 | 93 | public function getName() |
102 | 94 | { |
103 | 95 | return ( !empty( $this->stock ) ) ? $this->stock->title : ''; |
104 | 96 | } |
105 | - | |
97 | + | |
106 | 98 | /** |
107 | 99 | * @todo Check if needed |
108 | 100 | * |
... | ... | @@ -118,7 +110,7 @@ |
118 | 110 | */ |
119 | 111 | public function getStock() |
120 | 112 | { |
121 | - return $this->hasOne(Stock::className(), [ 'stock_id' => 'stock_id' ]); | |
113 | + return $this->hasOne(Stock::className(), [ 'id' => 'stock_id' ]); | |
122 | 114 | } |
123 | 115 | |
124 | 116 | public static function primaryKey() | ... | ... |
common/modules/product/models/ProductUnit.php
... | ... | @@ -10,7 +10,8 @@ |
10 | 10 | |
11 | 11 | /** |
12 | 12 | * This is the model class for table "product_unit". |
13 | - * @property integer $product_unit_id | |
13 | + * | |
14 | + * @property integer $id | |
14 | 15 | * @property boolean $is_default |
15 | 16 | * @property Category[] $categories |
16 | 17 | * @property ProductVariant[] $productVariants |
... | ... | @@ -74,8 +75,8 @@ |
74 | 75 | public function attributeLabels() |
75 | 76 | { |
76 | 77 | return [ |
77 | - 'product_unit_id' => Yii::t('product', 'Product Unit ID'), | |
78 | - 'is_default' => Yii::t('product', 'Is Default'), | |
78 | + 'id' => Yii::t('product', 'Product Unit ID'), | |
79 | + 'is_default' => Yii::t('product', 'Is Default'), | |
79 | 80 | ]; |
80 | 81 | } |
81 | 82 | |
... | ... | @@ -84,7 +85,7 @@ |
84 | 85 | */ |
85 | 86 | public function getCategories() |
86 | 87 | { |
87 | - return $this->hasMany(Category::className(), [ 'product_unit_id' => 'product_unit_id' ]); | |
88 | + return $this->hasMany(Category::className(), [ 'product_unit_id' => 'id' ]); | |
88 | 89 | } |
89 | 90 | |
90 | 91 | /** |
... | ... | @@ -92,6 +93,6 @@ |
92 | 93 | */ |
93 | 94 | public function getProductVariants() |
94 | 95 | { |
95 | - return $this->hasMany(ProductVariant::className(), [ 'product_unit_id' => 'product_unit_id' ]); | |
96 | + return $this->hasMany(ProductVariant::className(), [ 'product_unit_id' => 'id' ]); | |
96 | 97 | } |
97 | 98 | } | ... | ... |
common/modules/product/models/ProductUnitLang.php
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This is the model class for table "product_unit_lang". |
11 | + * | |
11 | 12 | * @property integer $product_unit_id |
12 | 13 | * @property integer $language_id |
13 | 14 | * @property string $title |
... | ... | @@ -76,7 +77,7 @@ |
76 | 77 | 'exist', |
77 | 78 | 'skipOnError' => true, |
78 | 79 | 'targetClass' => ProductUnit::className(), |
79 | - 'targetAttribute' => [ 'product_unit_id' => 'product_unit_id' ], | |
80 | + 'targetAttribute' => [ 'product_unit_id' => 'id' ], | |
80 | 81 | ], |
81 | 82 | ]; |
82 | 83 | } |
... | ... | @@ -89,7 +90,7 @@ |
89 | 90 | return [ |
90 | 91 | 'product_unit_id' => Yii::t('app', 'Product Unit ID'), |
91 | 92 | 'language_id' => Yii::t('app', 'Language ID'), |
92 | - 'title' => Yii::t('app', 'Name'), | |
93 | + 'title' => Yii::t('app', 'Name'), | |
93 | 94 | 'short' => Yii::t('app', 'Short'), |
94 | 95 | ]; |
95 | 96 | } |
... | ... | @@ -107,6 +108,6 @@ |
107 | 108 | */ |
108 | 109 | public function getProductUnit() |
109 | 110 | { |
110 | - return $this->hasOne(ProductUnit::className(), [ 'product_unit_id' => 'product_unit_id' ]); | |
111 | + return $this->hasOne(ProductUnit::className(), [ 'id' => 'product_unit_id' ]); | |
111 | 112 | } |
112 | 113 | } | ... | ... |
common/modules/product/models/ProductUnitSearch.php
... | ... | @@ -39,7 +39,7 @@ |
39 | 39 | 'safe', |
40 | 40 | ], |
41 | 41 | [ |
42 | - [ 'product_unit_id' ], | |
42 | + [ 'id' ], | |
43 | 43 | 'integer', |
44 | 44 | ], |
45 | 45 | [ |
... | ... | @@ -72,38 +72,44 @@ |
72 | 72 | |
73 | 73 | // add conditions that should always apply here |
74 | 74 | |
75 | - $dataProvider = new ActiveDataProvider([ | |
76 | - 'query' => $query, | |
77 | - 'sort' => [ | |
78 | - 'attributes' => [ | |
79 | - 'product_unit_id', | |
80 | - 'is_defaut', | |
81 | - 'title' => [ | |
82 | - 'asc' => [ 'product_unit_lang.title' => SORT_ASC ], | |
83 | - 'desc' => [ 'product_unit_lang.title' => SORT_DESC ], | |
75 | + $dataProvider = new ActiveDataProvider( | |
76 | + [ | |
77 | + 'query' => $query, | |
78 | + 'sort' => [ | |
79 | + 'attributes' => [ | |
80 | + 'id', | |
81 | + 'is_defaut', | |
82 | + 'title' => [ | |
83 | + 'asc' => [ 'product_unit_lang.title' => SORT_ASC ], | |
84 | + 'desc' => [ 'product_unit_lang.title' => SORT_DESC ], | |
85 | + ], | |
84 | 86 | ], |
85 | 87 | ], |
86 | - ], | |
87 | - ]); | |
88 | + ] | |
89 | + ); | |
88 | 90 | |
89 | 91 | $this->load($params); |
90 | 92 | |
91 | - if(!$this->validate()) { | |
93 | + if (!$this->validate()) { | |
92 | 94 | // uncomment the following line if you do not want to return any records when validation fails |
93 | 95 | // $query->where('0=1'); |
94 | 96 | return $dataProvider; |
95 | 97 | } |
96 | 98 | |
97 | 99 | // grid filtering conditions |
98 | - $query->andFilterWhere([ | |
99 | - 'product_unit_id' => $this->product_unit_id, | |
100 | - 'is_default' => $this->is_default, | |
101 | - ]) | |
102 | - ->andFilterWhere([ | |
103 | - 'ilike', | |
104 | - 'product_unit_lang.title', | |
105 | - $this->title, | |
106 | - ]); | |
100 | + $query->andFilterWhere( | |
101 | + [ | |
102 | + 'id' => $this->id, | |
103 | + 'is_default' => $this->is_default, | |
104 | + ] | |
105 | + ) | |
106 | + ->andFilterWhere( | |
107 | + [ | |
108 | + 'ilike', | |
109 | + 'product_unit_lang.title', | |
110 | + $this->title, | |
111 | + ] | |
112 | + ); | |
107 | 113 | |
108 | 114 | return $dataProvider; |
109 | 115 | } | ... | ... |
common/modules/product/models/ProductVariant.php
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | * This is the model class for table "product_variant". |
18 | 18 | * |
19 | 19 | * @todo Refactor |
20 | - * @property integer $product_variant_id | |
20 | + * @property integer $id | |
21 | 21 | * @property integer $product_id |
22 | 22 | * @property integer $remote_id |
23 | 23 | * @property string $sku |
... | ... | @@ -96,15 +96,15 @@ |
96 | 96 | 'directory' => 'products', |
97 | 97 | 'column' => 'image', |
98 | 98 | 'links' => [ |
99 | - 'product_id' => 'product_id', | |
100 | - 'product_variant_id' => 'product_variant_id', | |
99 | + 'product_id' => 'product_id', | |
100 | + 'id' => 'product_variant_id', | |
101 | 101 | ], |
102 | 102 | 'model' => ProductImage::className(), |
103 | 103 | ], |
104 | 104 | 'multipleImage' => [ |
105 | 105 | 'class' => MultipleImgBehavior::className(), |
106 | 106 | 'links' => [ |
107 | - 'product_variant_id' => 'product_variant_id', | |
107 | + 'id' => 'product_variant_id', | |
108 | 108 | ], |
109 | 109 | 'model' => ProductImage::className(), |
110 | 110 | 'config' => [ |
... | ... | @@ -162,7 +162,7 @@ |
162 | 162 | 'exist', |
163 | 163 | 'skipOnError' => true, |
164 | 164 | 'targetClass' => ProductUnit::className(), |
165 | - 'targetAttribute' => [ 'product_unit_id' => 'product_unit_id' ], | |
165 | + 'targetAttribute' => [ 'product_unit_id' => 'id' ], | |
166 | 166 | ], |
167 | 167 | ]; |
168 | 168 | } |
... | ... | @@ -173,16 +173,16 @@ |
173 | 173 | public function attributeLabels() |
174 | 174 | { |
175 | 175 | return [ |
176 | - 'product_variant_id' => Yii::t('product', 'Product Variant ID'), | |
177 | - 'product_id' => Yii::t('product', 'Product ID'), | |
178 | - 'sku' => Yii::t('product', 'Sku'), | |
179 | - 'price' => Yii::t('product', 'Price'), | |
180 | - 'price_old' => Yii::t('product', 'Price Old'), | |
181 | - 'stock' => Yii::t('product', 'Stock'), | |
182 | - 'product_unit_id' => Yii::t('product', 'Product Unit ID'), | |
183 | - 'stock_caption' => Yii::t('product', 'Stock'), | |
184 | - 'image' => Yii::t('product', 'Image'), | |
185 | - 'images' => Yii::t('product', 'Images'), | |
176 | + 'id' => Yii::t('product', 'Product Variant ID'), | |
177 | + 'product_id' => Yii::t('product', 'Product ID'), | |
178 | + 'sku' => Yii::t('product', 'Sku'), | |
179 | + 'price' => Yii::t('product', 'Price'), | |
180 | + 'price_old' => Yii::t('product', 'Price Old'), | |
181 | + 'stock' => Yii::t('product', 'Stock'), | |
182 | + 'product_unit_id' => Yii::t('product', 'Product Unit ID'), | |
183 | + 'stock_caption' => Yii::t('product', 'Stock'), | |
184 | + 'image' => Yii::t('product', 'Image'), | |
185 | + 'images' => Yii::t('product', 'Images'), | |
186 | 186 | ]; |
187 | 187 | } |
188 | 188 | |
... | ... | @@ -191,7 +191,7 @@ |
191 | 191 | */ |
192 | 192 | public function getProductUnit() |
193 | 193 | { |
194 | - return $this->hasOne(ProductUnit::className(), [ 'product_unit_id' => 'product_unit_id' ]); | |
194 | + return $this->hasOne(ProductUnit::className(), [ 'id' => 'product_unit_id' ]); | |
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
... | ... | @@ -204,13 +204,13 @@ |
204 | 204 | |
205 | 205 | public function getProductStock() |
206 | 206 | { |
207 | - return $this->hasMany(ProductStock::className(), [ 'product_variant_id' => 'product_variant_id' ]); | |
207 | + return $this->hasMany(ProductStock::className(), [ 'product_variant_id' => 'id' ]); | |
208 | 208 | } |
209 | 209 | |
210 | 210 | public function getQuantity() |
211 | 211 | { |
212 | 212 | return ProductStock::find() |
213 | - ->where([ 'product_variant_id' => $this->product_variant_id ]) | |
213 | + ->where([ 'product_variant_id' => $this->id ]) | |
214 | 214 | ->sum('quantity'); |
215 | 215 | } |
216 | 216 | |
... | ... | @@ -224,20 +224,20 @@ |
224 | 224 | |
225 | 225 | public function getVariantStocks() |
226 | 226 | { |
227 | - return $this->hasMany(ProductStock::className(), [ 'product_variant_id' => 'product_variant_id' ]) | |
227 | + return $this->hasMany(ProductStock::className(), [ 'product_variant_id' => 'id' ]) | |
228 | 228 | ->joinWith('stock'); |
229 | 229 | } |
230 | 230 | |
231 | 231 | public function getStocks() |
232 | 232 | { |
233 | - return $this->hasMany(Stock::className(), [ 'stock_id' => 'stock_id' ]) | |
234 | - ->viaTable(ProductStock::tableName(), [ 'product_variant_id' => 'product_variant_id' ]); | |
233 | + return $this->hasMany(Stock::className(), [ 'id' => 'stock_id' ]) | |
234 | + ->viaTable(ProductStock::tableName(), [ 'product_variant_id' => 'id' ]); | |
235 | 235 | } |
236 | 236 | |
237 | 237 | public function getFilters() |
238 | 238 | { |
239 | 239 | return $this->hasMany(TaxOption::className(), [ 'tax_option_id' => 'option_id' ]) |
240 | - ->viaTable('product_variant_option', [ 'product_variant_id' => 'product_variant_id' ]) | |
240 | + ->viaTable('product_variant_option', [ 'product_variant_id' => 'id' ]) | |
241 | 241 | ->joinWith('taxGroup.lang', true, 'INNER JOIN') |
242 | 242 | ->joinWith('lang', true, 'INNER JOIN'); |
243 | 243 | } |
... | ... | @@ -255,7 +255,7 @@ |
255 | 255 | public function getOptions() |
256 | 256 | { |
257 | 257 | return $this->hasMany(TaxOption::className(), [ 'tax_option_id' => 'option_id' ]) |
258 | - ->viaTable('product_variant_option', [ 'product_variant_id' => 'product_variant_id' ]); | |
258 | + ->viaTable('product_variant_option', [ 'product_variant_id' => 'id' ]); | |
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
... | ... | @@ -282,11 +282,6 @@ |
282 | 282 | return $groups; |
283 | 283 | } |
284 | 284 | |
285 | - public function getId() | |
286 | - { | |
287 | - return $this->product_variant_id; | |
288 | - } | |
289 | - | |
290 | 285 | /** |
291 | 286 | * @todo Check if needed |
292 | 287 | * |
... | ... | @@ -334,7 +329,7 @@ |
334 | 329 | } |
335 | 330 | |
336 | 331 | if (!empty( $this->stocks )) { |
337 | - ProductStock::deleteAll([ 'product_variant_id' => $this->product_variant_id ]); | |
332 | + ProductStock::deleteAll([ 'product_variant_id' => $this->id ]); | |
338 | 333 | foreach ($this->stocks as $id => $quantity) { |
339 | 334 | /** |
340 | 335 | * @var ProductStock $productStock |
... | ... | @@ -342,7 +337,7 @@ |
342 | 337 | $productStock = ProductStock::find() |
343 | 338 | ->where( |
344 | 339 | [ |
345 | - 'product_variant_id' => $this->product_variant_id, | |
340 | + 'product_variant_id' => $this->id, | |
346 | 341 | 'stock_id' => $id, |
347 | 342 | ] |
348 | 343 | ) | ... | ... |
common/modules/product/models/ProductVariantLang.php
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This is the model class for table "product_variant_lang". |
11 | + * | |
11 | 12 | * @property integer $product_variant_id |
12 | 13 | * @property integer $language_id |
13 | 14 | * @property string $title |
... | ... | @@ -72,7 +73,7 @@ |
72 | 73 | 'exist', |
73 | 74 | 'skipOnError' => true, |
74 | 75 | 'targetClass' => ProductVariant::className(), |
75 | - 'targetAttribute' => [ 'product_variant_id' => 'product_variant_id' ], | |
76 | + 'targetAttribute' => [ 'product_variant_id' => 'id' ], | |
76 | 77 | ], |
77 | 78 | ]; |
78 | 79 | } |
... | ... | @@ -85,7 +86,7 @@ |
85 | 86 | return [ |
86 | 87 | 'product_variant_id' => Yii::t('app', 'Product Variant ID'), |
87 | 88 | 'language_id' => Yii::t('app', 'Language ID'), |
88 | - 'title' => Yii::t('app', 'Name'), | |
89 | + 'title' => Yii::t('app', 'Name'), | |
89 | 90 | ]; |
90 | 91 | } |
91 | 92 | |
... | ... | @@ -102,6 +103,6 @@ |
102 | 103 | */ |
103 | 104 | public function getProductVariant() |
104 | 105 | { |
105 | - return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ]); | |
106 | + return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]); | |
106 | 107 | } |
107 | 108 | } | ... | ... |
common/modules/product/models/ProductVariantOption.php
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | |
8 | 8 | /** |
9 | 9 | * This is the model class for table "product_variant_option". |
10 | + * | |
10 | 11 | * @property integer $product_variant_id |
11 | 12 | * @property integer $option_id |
12 | 13 | * @property ProductVariant $productVariant |
... | ... | @@ -48,7 +49,7 @@ |
48 | 49 | 'exist', |
49 | 50 | 'skipOnError' => true, |
50 | 51 | 'targetClass' => ProductVariant::className(), |
51 | - 'targetAttribute' => [ 'product_variant_id' => 'product_variant_id' ], | |
52 | + 'targetAttribute' => [ 'product_variant_id' => 'id' ], | |
52 | 53 | ], |
53 | 54 | [ |
54 | 55 | [ 'option_id' ], |
... | ... | @@ -76,7 +77,7 @@ |
76 | 77 | */ |
77 | 78 | public function getProductVariant() |
78 | 79 | { |
79 | - return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ]); | |
80 | + return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]); | |
80 | 81 | } |
81 | 82 | |
82 | 83 | /** | ... | ... |
common/modules/product/models/ProductVariantSearch.php
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 | ], |
35 | 35 | [ |
36 | 36 | [ |
37 | - 'product_variant_id', | |
37 | + 'id', | |
38 | 38 | 'stock', |
39 | 39 | ], |
40 | 40 | 'integer', |
... | ... | @@ -72,53 +72,65 @@ |
72 | 72 | |
73 | 73 | // add conditions that should always apply here |
74 | 74 | |
75 | - $dataProvider = new ActiveDataProvider([ | |
76 | - 'query' => $query, | |
77 | - ]); | |
75 | + $dataProvider = new ActiveDataProvider( | |
76 | + [ | |
77 | + 'query' => $query, | |
78 | + ] | |
79 | + ); | |
78 | 80 | |
79 | 81 | $this->load($params); |
80 | 82 | |
81 | - if(!$this->validate()) { | |
83 | + if (!$this->validate()) { | |
82 | 84 | // uncomment the following line if you do not want to return any records when validation fails |
83 | 85 | // $query->where('0=1'); |
84 | 86 | return $dataProvider; |
85 | 87 | } |
86 | 88 | |
87 | - $dataProvider->setSort([ | |
88 | - 'attributes' => [ | |
89 | - 'product_variant_id', | |
90 | - 'sku', | |
91 | - 'variantName' => [ | |
92 | - 'asc' => [ 'product_variant_lang.title' => SORT_ASC ], | |
93 | - 'desc' => [ 'product_variant_lang.title' => SORT_DESC ], | |
89 | + $dataProvider->setSort( | |
90 | + [ | |
91 | + 'attributes' => [ | |
92 | + 'id', | |
93 | + 'sku', | |
94 | + 'variantName' => [ | |
95 | + 'asc' => [ 'product_variant_lang.title' => SORT_ASC ], | |
96 | + 'desc' => [ 'product_variant_lang.title' => SORT_DESC ], | |
97 | + ], | |
98 | + 'price', | |
99 | + 'price_old', | |
100 | + 'stock', | |
94 | 101 | ], |
95 | - 'price', | |
96 | - 'price_old', | |
97 | - 'stock', | |
98 | - ], | |
99 | - ]); | |
102 | + ] | |
103 | + ); | |
100 | 104 | |
101 | - $query->andFilterWhere([ | |
102 | - 'price' => $this->price, | |
103 | - 'price_old' => $this->price_old, | |
104 | - 'stock' => $this->stock, | |
105 | - ]); | |
105 | + $query->andFilterWhere( | |
106 | + [ | |
107 | + 'price' => $this->price, | |
108 | + 'price_old' => $this->price_old, | |
109 | + 'stock' => $this->stock, | |
110 | + ] | |
111 | + ); | |
106 | 112 | |
107 | - $query->andFilterWhere([ | |
108 | - 'ilike', | |
109 | - 'product_variant_lang.title', | |
110 | - $this->variantName, | |
111 | - ]) | |
112 | - ->andFilterWhere([ | |
113 | - 'ilike', | |
114 | - 'sku', | |
115 | - $this->sku, | |
116 | - ]); | |
113 | + $query->andFilterWhere( | |
114 | + [ | |
115 | + 'ilike', | |
116 | + 'product_variant_lang.title', | |
117 | + $this->variantName, | |
118 | + ] | |
119 | + ) | |
120 | + ->andFilterWhere( | |
121 | + [ | |
122 | + 'ilike', | |
123 | + 'sku', | |
124 | + $this->sku, | |
125 | + ] | |
126 | + ); | |
117 | 127 | |
118 | - $query->groupBy([ | |
119 | - 'product_variant.product_variant_id', | |
120 | - 'product_variant_lang.title', | |
121 | - ]); | |
128 | + $query->groupBy( | |
129 | + [ | |
130 | + 'product_variant.id', | |
131 | + 'product_variant_lang.title', | |
132 | + ] | |
133 | + ); | |
122 | 134 | |
123 | 135 | return $dataProvider; |
124 | 136 | } | ... | ... |
common/modules/product/models/Stock.php
... | ... | @@ -7,8 +7,9 @@ |
7 | 7 | |
8 | 8 | /** |
9 | 9 | * This is the model class for table "stock". |
10 | - * @property integer $stock_id | |
11 | - * @property string $title | |
10 | + * | |
11 | + * @property integer $id | |
12 | + * @property string $title | |
12 | 13 | * @property ProductStock[] $productStocks |
13 | 14 | */ |
14 | 15 | class Stock extends ActiveRecord |
... | ... | @@ -46,8 +47,25 @@ |
46 | 47 | public function attributeLabels() |
47 | 48 | { |
48 | 49 | return [ |
49 | - 'stock_id' => Yii::t('product', 'Stock ID'), | |
50 | - 'title' => Yii::t('product', 'Name'), | |
50 | + 'id' => Yii::t('product', 'Stock ID'), | |
51 | + 'title' => Yii::t('product', 'Name'), | |
51 | 52 | ]; |
52 | 53 | } |
54 | + | |
55 | + public function getProductStocks() | |
56 | + { | |
57 | + return $this->hasMany(ProductStock::className(), [ 'stock_id' => 'id' ]); | |
58 | + } | |
59 | + | |
60 | + public function getProductVariants() | |
61 | + { | |
62 | + return $this->hasMany(ProductVariant::className(), [ 'id' => 'product_variant_id' ]) | |
63 | + ->via('productStocks'); | |
64 | + } | |
65 | + | |
66 | + public function getProducts() | |
67 | + { | |
68 | + return $this->hasMany(Product::className(), [ 'id' => 'product_id' ]) | |
69 | + ->via('productVariants'); | |
70 | + } | |
53 | 71 | } | ... | ... |
common/modules/product/views/manage/_form.php
... | ... | @@ -22,76 +22,98 @@ |
22 | 22 | |
23 | 23 | <div class="product-form"> |
24 | 24 | |
25 | - <?php $form = ActiveForm::begin([ | |
26 | - 'options' => [ 'enctype' => 'multipart/form-data' ], | |
27 | - ]); ?> | |
25 | + <?php $form = ActiveForm::begin( | |
26 | + [ | |
27 | + 'options' => [ 'enctype' => 'multipart/form-data' ], | |
28 | + ] | |
29 | + ); ?> | |
28 | 30 | |
29 | 31 | <?= $form->field($model, 'is_top') |
30 | 32 | ->checkbox([ 'label' => 'ะขะะ' ]) ?> |
31 | 33 | <?= $form->field($model, 'is_new') |
32 | 34 | ->checkbox([ 'label' => 'ะะพะฒะธะฝะบะฐ' ]) ?> |
33 | - <?= $form->field($model, 'akciya') | |
35 | + <?= $form->field($model, 'is_discount') | |
34 | 36 | ->checkbox([ 'label' => 'ะะบัะธะพะฝะฝัะน' ]) ?> |
35 | 37 | |
36 | 38 | <?= $form->field($model, 'video') |
37 | 39 | ->textarea(); ?> |
38 | 40 | |
39 | 41 | <?= $form->field($model, 'brand_id') |
40 | - ->dropDownList(ArrayHelper::map(ProductHelper::getBrands() | |
41 | - ->with('lang') | |
42 | - ->all(), 'id', 'lang.title'), [ | |
43 | - 'prompt' => Yii::t('product', 'Select brand'), | |
44 | - ]) ?> | |
42 | + ->dropDownList( | |
43 | + ArrayHelper::map( | |
44 | + ProductHelper::getBrands() | |
45 | + ->with('lang') | |
46 | + ->all(), | |
47 | + 'id', | |
48 | + 'lang.title' | |
49 | + ), | |
50 | + [ | |
51 | + 'prompt' => Yii::t('product', 'Select brand'), | |
52 | + ] | |
53 | + ) ?> | |
45 | 54 | |
46 | 55 | <?= $form->field($model, 'categories') |
47 | - ->widget(Select2::className(), [ | |
48 | - 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'id', 'lang.title'), | |
49 | - 'language' => 'ru', | |
50 | - 'options' => [ | |
51 | - 'placeholder' => Yii::t('product', 'Select categories'), | |
52 | - 'multiple' => true, | |
53 | - ], | |
54 | - 'pluginOptions' => [ | |
55 | - 'allowClear' => true, | |
56 | - ], | |
57 | - ]) ?> | |
56 | + ->widget( | |
57 | + Select2::className(), | |
58 | + [ | |
59 | + 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'id', 'lang.title'), | |
60 | + 'language' => 'ru', | |
61 | + 'options' => [ | |
62 | + 'placeholder' => Yii::t('product', 'Select categories'), | |
63 | + 'multiple' => true, | |
64 | + ], | |
65 | + 'pluginOptions' => [ | |
66 | + 'allowClear' => true, | |
67 | + ], | |
68 | + ] | |
69 | + ) ?> | |
58 | 70 | |
59 | 71 | <?= $form->field($model, 'imagesUpload[]') |
60 | - ->widget(\kartik\file\FileInput::className(), [ | |
61 | - 'language' => 'ru', | |
62 | - 'options' => [ | |
63 | - 'accept' => 'image/*', | |
64 | - 'multiple' => true, | |
65 | - ], | |
66 | - 'pluginOptions' => [ | |
67 | - 'allowedFileExtensions' => [ | |
68 | - 'jpg', | |
69 | - 'gif', | |
70 | - 'png', | |
72 | + ->widget( | |
73 | + \kartik\file\FileInput::className(), | |
74 | + [ | |
75 | + 'language' => 'ru', | |
76 | + 'options' => [ | |
77 | + 'accept' => 'image/*', | |
78 | + 'multiple' => true, | |
79 | + ], | |
80 | + 'pluginOptions' => [ | |
81 | + 'allowedFileExtensions' => [ | |
82 | + 'jpg', | |
83 | + 'gif', | |
84 | + 'png', | |
85 | + ], | |
86 | + 'initialPreview' => !empty( $model->imagesHTML ) ? $model->imagesHTML : [], | |
87 | + 'initialPreviewConfig' => $model->imagesConfig, | |
88 | + 'overwriteInitial' => false, | |
89 | + 'showRemove' => false, | |
90 | + 'showUpload' => false, | |
91 | + 'uploadAsync' => !empty( $model->id ), | |
92 | + 'previewFileType' => 'image', | |
71 | 93 | ], |
72 | - 'initialPreview' => !empty( $model->imagesHTML ) ? $model->imagesHTML : [], | |
73 | - 'initialPreviewConfig' => $model->imagesConfig, | |
74 | - 'overwriteInitial' => false, | |
75 | - 'showRemove' => false, | |
76 | - 'showUpload' => false, | |
77 | - 'uploadAsync' => !empty( $model->id ), | |
78 | - 'previewFileType' => 'image', | |
79 | - ], | |
80 | - ]); ?> | |
94 | + ] | |
95 | + ); ?> | |
81 | 96 | |
82 | - <?php if(!empty( $groups )) { | |
83 | - foreach($groups->with('lang') | |
84 | - ->all() as $group) { | |
97 | + <?php if (!empty( $groups )) { | |
98 | + foreach ($groups->with('lang') | |
99 | + ->all() as $group) { | |
85 | 100 | /** |
86 | 101 | * @var TaxGroup $group |
87 | 102 | */ |
88 | 103 | echo $form->field($model, 'options') |
89 | - ->checkboxList(ArrayHelper::map($group->getOptions() | |
90 | - ->with('lang') | |
91 | - ->all(), 'tax_option_id', 'lang.value'), [ | |
92 | - 'multiple' => true, | |
93 | - 'unselect' => NULL, | |
94 | - ]) | |
104 | + ->checkboxList( | |
105 | + ArrayHelper::map( | |
106 | + $group->getOptions() | |
107 | + ->with('lang') | |
108 | + ->all(), | |
109 | + 'tax_option_id', | |
110 | + 'lang.value' | |
111 | + ), | |
112 | + [ | |
113 | + 'multiple' => true, | |
114 | + 'unselect' => null, | |
115 | + ] | |
116 | + ) | |
95 | 117 | ->label($group->lang->title); |
96 | 118 | } |
97 | 119 | } |
... | ... | @@ -99,14 +121,19 @@ |
99 | 121 | |
100 | 122 | <hr> |
101 | 123 | |
102 | - <?= LanguageForm::widget([ | |
103 | - 'modelLangs' => $modelLangs, | |
104 | - 'formView' => '@common/modules/product/views/manage/_form_language', | |
105 | - 'form' => $form, | |
106 | - ]) ?> | |
124 | + <?= LanguageForm::widget( | |
125 | + [ | |
126 | + 'modelLangs' => $modelLangs, | |
127 | + 'formView' => '@common/modules/product/views/manage/_form_language', | |
128 | + 'form' => $form, | |
129 | + ] | |
130 | + ) ?> | |
107 | 131 | |
108 | 132 | <div class="form-group"> |
109 | - <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?> | |
133 | + <?= Html::submitButton( | |
134 | + $model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), | |
135 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | |
136 | + ) ?> | |
110 | 137 | </div> |
111 | 138 | |
112 | 139 | <?php ActiveForm::end(); ?> | ... | ... |
common/modules/product/views/manage/index.php
... | ... | @@ -116,9 +116,9 @@ |
116 | 116 | ], |
117 | 117 | [ |
118 | 118 | 'class' => 'yii\grid\ActionColumn', |
119 | - 'template' => '{items} {view} |{is_top} {is_new} {akciya} | {update} {delete}', | |
119 | + 'template' => '{items} {view} |{is_top} {is_new} {is_discount} | {update} {delete}', | |
120 | 120 | 'buttons' => [ |
121 | - 'is_top' => function ($url, $model) { | |
121 | + 'is_top' => function ($url, $model) { | |
122 | 122 | return Html::a( |
123 | 123 | '<span class="glyphicon glyphicon-star' . ( $model->is_top ? '' : '-empty' ) . '"></span>', |
124 | 124 | $url, |
... | ... | @@ -127,7 +127,7 @@ |
127 | 127 | ] |
128 | 128 | ); |
129 | 129 | }, |
130 | - 'is_new' => function ($url, $model) { | |
130 | + 'is_new' => function ($url, $model) { | |
131 | 131 | return Html::a( |
132 | 132 | '<span class="glyphicon glyphicon-heart' . ( $model->is_new ? '' : '-empty' ) . '"></span>', |
133 | 133 | $url, |
... | ... | @@ -136,19 +136,19 @@ |
136 | 136 | ] |
137 | 137 | ); |
138 | 138 | }, |
139 | - 'akciya' => function ($url, $model) { | |
139 | + 'is_discount' => function ($url, $model) { | |
140 | 140 | return Html::a( |
141 | - '<span class="glyphicon glyphicon-tag' . ( $model->akciya ? 's' : '' ) . '"></span>', | |
141 | + '<span class="glyphicon glyphicon-tag' . ( $model->is_discount ? 's' : '' ) . '"></span>', | |
142 | 142 | $url, |
143 | 143 | [ |
144 | 144 | 'title' => Yii::t( |
145 | 145 | 'product', |
146 | - ( $model->akciya ? 'Set not is promotion' : 'Set is promotion' ) | |
146 | + ( $model->is_discount ? 'Set not is promotion' : 'Set is promotion' ) | |
147 | 147 | ), |
148 | 148 | ] |
149 | 149 | ); |
150 | 150 | }, |
151 | - 'items' => function ($url, $model) { | |
151 | + 'items' => function ($url, $model) { | |
152 | 152 | return Html::a( |
153 | 153 | '<span class="glyphicon glyphicon-th-list"></span>', |
154 | 154 | $url, |
... | ... | @@ -188,10 +188,10 @@ |
188 | 188 | ] |
189 | 189 | ); |
190 | 190 | break; |
191 | - case 'akciya': | |
191 | + case 'is_discount': | |
192 | 192 | return \yii\helpers\Url::to( |
193 | 193 | [ |
194 | - 'manage/akciya', | |
194 | + 'manage/is-discount', | |
195 | 195 | 'id' => $model->id, |
196 | 196 | ] |
197 | 197 | ); | ... | ... |
common/modules/product/views/manage/view.php
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | $variant->lang->title, |
38 | 38 | [ |
39 | 39 | '/product/variant/view', |
40 | - 'id' => $variant->product_variant_id, | |
40 | + 'id' => $variant->id, | |
41 | 41 | ] |
42 | 42 | ) . '<br>'; |
43 | 43 | } |
... | ... | @@ -109,8 +109,8 @@ |
109 | 109 | 'format' => 'html', |
110 | 110 | ], |
111 | 111 | [ |
112 | - 'attribute' => 'akciya', | |
113 | - 'value' => $model->akciya ? Html::tag( | |
112 | + 'attribute' => 'is_discount', | |
113 | + 'value' => $model->is_discount ? Html::tag( | |
114 | 114 | 'span', |
115 | 115 | '', |
116 | 116 | [ 'class' => 'glyphicon glyphicon-ok' ] | ... | ... |
common/modules/product/views/product-unit/index.php
... | ... | @@ -22,25 +22,27 @@ |
22 | 22 | <p> |
23 | 23 | <?= Html::a(Yii::t('product', 'Create Product Unit'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> |
24 | 24 | </p> |
25 | - <?= GridView::widget([ | |
26 | - 'dataProvider' => $dataProvider, | |
27 | - 'filterModel' => $searchModel, | |
28 | - 'columns' => [ | |
29 | - 'product_unit_id', | |
30 | - [ | |
31 | - 'attribute' => 'is_default', | |
32 | - 'format' => 'boolean', | |
33 | - 'filter' => [ | |
34 | - \Yii::$app->formatter->asBoolean(false), | |
35 | - \Yii::$app->formatter->asBoolean(true), | |
25 | + <?= GridView::widget( | |
26 | + [ | |
27 | + 'dataProvider' => $dataProvider, | |
28 | + 'filterModel' => $searchModel, | |
29 | + 'columns' => [ | |
30 | + 'id', | |
31 | + [ | |
32 | + 'attribute' => 'is_default', | |
33 | + 'format' => 'boolean', | |
34 | + 'filter' => [ | |
35 | + \Yii::$app->formatter->asBoolean(false), | |
36 | + \Yii::$app->formatter->asBoolean(true), | |
37 | + ], | |
36 | 38 | ], |
39 | + [ | |
40 | + 'attribute' => 'title', | |
41 | + 'value' => 'lang.title', | |
42 | + ], | |
43 | + 'lang.short', | |
44 | + [ 'class' => 'yii\grid\ActionColumn' ], | |
37 | 45 | ], |
38 | - [ | |
39 | - 'attribute' => 'title', | |
40 | - 'value' => 'lang.title', | |
41 | - ], | |
42 | - 'lang.short', | |
43 | - [ 'class' => 'yii\grid\ActionColumn' ], | |
44 | - ], | |
45 | - ]); ?> | |
46 | + ] | |
47 | + ); ?> | |
46 | 48 | </div> | ... | ... |
common/modules/product/views/product-unit/update.php
common/modules/product/views/product-unit/view.php
... | ... | @@ -22,30 +22,40 @@ |
22 | 22 | <h1><?= Html::encode($this->title) ?></h1> |
23 | 23 | |
24 | 24 | <p> |
25 | - <?= Html::a(Yii::t('product', 'Update'), [ | |
26 | - 'update', | |
27 | - 'id' => $model->product_unit_id, | |
28 | - ], [ 'class' => 'btn btn-primary' ]) ?> | |
29 | - <?= Html::a(Yii::t('product', 'Delete'), [ | |
30 | - 'delete', | |
31 | - 'id' => $model->product_unit_id, | |
32 | - ], [ | |
33 | - 'class' => 'btn btn-danger', | |
34 | - 'data' => [ | |
35 | - 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'), | |
36 | - 'method' => 'post', | |
25 | + <?= Html::a( | |
26 | + Yii::t('product', 'Update'), | |
27 | + [ | |
28 | + 'update', | |
29 | + 'id' => $model->id, | |
37 | 30 | ], |
38 | - ]) ?> | |
31 | + [ 'class' => 'btn btn-primary' ] | |
32 | + ) ?> | |
33 | + <?= Html::a( | |
34 | + Yii::t('product', 'Delete'), | |
35 | + [ | |
36 | + 'delete', | |
37 | + 'id' => $model->id, | |
38 | + ], | |
39 | + [ | |
40 | + 'class' => 'btn btn-danger', | |
41 | + 'data' => [ | |
42 | + 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'), | |
43 | + 'method' => 'post', | |
44 | + ], | |
45 | + ] | |
46 | + ) ?> | |
39 | 47 | </p> |
40 | 48 | |
41 | - <?= DetailView::widget([ | |
42 | - 'model' => $model, | |
43 | - 'attributes' => [ | |
44 | - 'product_unit_id', | |
45 | - 'is_default:boolean', | |
46 | - 'lang.title', | |
47 | - 'lang.short', | |
48 | - ], | |
49 | - ]) ?> | |
49 | + <?= DetailView::widget( | |
50 | + [ | |
51 | + 'model' => $model, | |
52 | + 'attributes' => [ | |
53 | + 'id', | |
54 | + 'is_default:boolean', | |
55 | + 'lang.title', | |
56 | + 'lang.short', | |
57 | + ], | |
58 | + ] | |
59 | + ) ?> | |
50 | 60 | |
51 | 61 | </div> | ... | ... |
common/modules/product/views/variant/_form.php
... | ... | @@ -78,7 +78,7 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) { |
78 | 78 | 'overwriteInitial' => false, |
79 | 79 | 'showRemove' => false, |
80 | 80 | 'showUpload' => false, |
81 | - 'uploadAsync' => !empty( $model->product_variant_id ), | |
81 | + 'uploadAsync' => !empty( $model->id ), | |
82 | 82 | 'previewFileType' => 'image', |
83 | 83 | ], |
84 | 84 | ] | ... | ... |
common/modules/product/views/variant/index.php
... | ... | @@ -50,7 +50,7 @@ |
50 | 50 | 'dataProvider' => $dataProvider, |
51 | 51 | 'filterModel' => $searchModel, |
52 | 52 | 'columns' => [ |
53 | - 'product_variant_id', | |
53 | + 'id', | |
54 | 54 | [ |
55 | 55 | 'attribute' => 'variantName', |
56 | 56 | 'value' => 'lang.title', |
... | ... | @@ -70,7 +70,7 @@ |
70 | 70 | [ |
71 | 71 | 'view', |
72 | 72 | 'product_id' => $model->product_id, |
73 | - 'id' => $model->product_variant_id, | |
73 | + 'id' => $model->id, | |
74 | 74 | ] |
75 | 75 | ), |
76 | 76 | [ |
... | ... | @@ -85,7 +85,7 @@ |
85 | 85 | [ |
86 | 86 | 'update', |
87 | 87 | 'product_id' => $model->product_id, |
88 | - 'id' => $model->product_variant_id, | |
88 | + 'id' => $model->id, | |
89 | 89 | ] |
90 | 90 | ), |
91 | 91 | [ |
... | ... | @@ -101,7 +101,7 @@ |
101 | 101 | [ |
102 | 102 | 'delete', |
103 | 103 | 'product_id' => $model->product_id, |
104 | - 'id' => $model->product_variant_id, | |
104 | + 'id' => $model->id, | |
105 | 105 | ] |
106 | 106 | ), |
107 | 107 | [ | ... | ... |
common/modules/product/views/variant/update.php
common/modules/product/views/variant/view.php
... | ... | @@ -47,7 +47,7 @@ |
47 | 47 | Yii::t('product', 'Update'), |
48 | 48 | [ |
49 | 49 | 'update', |
50 | - 'id' => $model->product_variant_id, | |
50 | + 'id' => $model->id, | |
51 | 51 | ], |
52 | 52 | [ 'class' => 'btn btn-primary' ] |
53 | 53 | ) ?> |
... | ... | @@ -55,7 +55,7 @@ |
55 | 55 | Yii::t('product', 'Delete'), |
56 | 56 | [ |
57 | 57 | 'delete', |
58 | - 'id' => $model->product_variant_id, | |
58 | + 'id' => $model->id, | |
59 | 59 | ], |
60 | 60 | [ |
61 | 61 | 'class' => 'btn btn-danger', |
... | ... | @@ -71,7 +71,7 @@ |
71 | 71 | [ |
72 | 72 | 'model' => $model, |
73 | 73 | 'attributes' => [ |
74 | - 'product_variant_id', | |
74 | + 'id', | |
75 | 75 | 'lang.title', |
76 | 76 | 'sku', |
77 | 77 | 'price', | ... | ... |
common/modules/product/widgets/views/product_smart.php
... | ... | @@ -11,24 +11,36 @@ |
11 | 11 | <div class="item_container"> |
12 | 12 | <input class="prodInfo" type="hidden" value="[]"> |
13 | 13 | <div class="title"> |
14 | - <?= Html::a($product->lang->title, Url::to([ | |
15 | - 'catalog/product', | |
16 | - 'product' => $product->lang->alias, | |
17 | - ]), [ 'class' => 'btn-product-details' ]) ?> | |
14 | + <?= Html::a( | |
15 | + $product->lang->title, | |
16 | + Url::to( | |
17 | + [ | |
18 | + 'catalog/product', | |
19 | + 'product' => $product->lang->alias, | |
20 | + ] | |
21 | + ), | |
22 | + [ 'class' => 'btn-product-details' ] | |
23 | + ) ?> | |
18 | 24 | </div> |
19 | 25 | <div class="img"> |
20 | - <a class="btn-product-details" href="<?= Url::to([ | |
21 | - 'catalog/product', | |
22 | - 'product' => $product->lang->alias, | |
23 | - ]) ?>"> | |
24 | - <?= \common\components\artboximage\ArtboxImageHelper::getImage($product->enabledVariants[ 0 ]->imageUrl, 'list', [ | |
25 | - 'alt' => $product->category->lang->title . ' ' . $product->fullname, | |
26 | - 'title' => $product->category->lang->title . ' ' . $product->fullname, | |
27 | - 'class' => 'selected', | |
28 | - ]) ?> | |
26 | + <a class="btn-product-details" href="<?= Url::to( | |
27 | + [ | |
28 | + 'catalog/product', | |
29 | + 'product' => $product->lang->alias, | |
30 | + ] | |
31 | + ) ?>"> | |
32 | + <?= \common\components\artboximage\ArtboxImageHelper::getImage( | |
33 | + $product->enabledVariants[ 0 ]->imageUrl, | |
34 | + 'list', | |
35 | + [ | |
36 | + 'alt' => $product->category->lang->title . ' ' . $product->fullname, | |
37 | + 'title' => $product->category->lang->title . ' ' . $product->fullname, | |
38 | + 'class' => 'selected', | |
39 | + ] | |
40 | + ) ?> | |
29 | 41 | </a> |
30 | 42 | <div class="info_icons"> |
31 | - <a href="#" class="btn buy_button" data-toggle="modal" data-target="#buyForm" data-id="<?= $product->variant->product_variant_id; ?>" lang="145">ะัะฟะธัั</a> | |
43 | + <a href="#" class="btn buy_button" data-toggle="modal" data-target="#buyForm" data-id="<?= $product->variant->id; ?>" lang="145">ะัะฟะธัั</a> | |
32 | 44 | <ul class="ul wishlike_block hidden"> |
33 | 45 | <li class="compare hidden"> |
34 | 46 | <a onclick="add2compare(); return false;" class="compare compare_text_link_3631483" href="#">ะ ััะฐะฒะฝะตะฝะธั</a> |
... | ... | @@ -57,9 +69,9 @@ |
57 | 69 | |
58 | 70 | <li><span>ะัะตะฝะด:</span> <?= $product->brand->lang->title ?></li> |
59 | 71 | |
60 | - <?php foreach($product->getActiveProperties($product->category->id) as $group): ?> | |
72 | + <?php foreach ($product->getActiveProperties($product->category->id) as $group): ?> | |
61 | 73 | <li> |
62 | - <span><?= $group->title ?> <?php foreach( $group->options as $option ) : ?> </span><?= $option->value ?><?php endforeach ?> | |
74 | + <span><?= $group->title ?> <?php foreach ( $group->options as $option ) : ?> </span><?= $option->value ?><?php endforeach ?> | |
63 | 75 | </li> |
64 | 76 | <?php endforeach; ?> |
65 | 77 | |
... | ... | @@ -78,7 +90,7 @@ |
78 | 90 | |
79 | 91 | // ะตััั ัะบะธะดะบะฐ |
80 | 92 | echo '<p class="cost">'; |
81 | - if($product->enabledVariants[ 0 ]->price_old != 0 && $product->enabledVariants[ 0 ]->price_old != $product->enabledVariants[ 0 ]->price) { | |
93 | + if ($product->enabledVariants[ 0 ]->price_old != 0 && $product->enabledVariants[ 0 ]->price_old != $product->enabledVariants[ 0 ]->price) { | |
82 | 94 | echo '<strike><span id=\'old_cost\' itemprop="price">' . $product->enabledVariants[ 0 ]->price_old . '</span> ะณัะฝ.</strike> '; |
83 | 95 | echo $product->enabledVariants[ 0 ]->price . ' <span>ะณัะฝ.</span></p>'; |
84 | 96 | } else { | ... | ... |
common/modules/rubrication/models/TaxOption.php
... | ... | @@ -181,7 +181,7 @@ |
181 | 181 | |
182 | 182 | public function getProductVariants() |
183 | 183 | { |
184 | - return $this->hasMany(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ]) | |
184 | + return $this->hasMany(ProductVariant::className(), [ 'id' => 'product_variant_id' ]) | |
185 | 185 | ->viaTable('product_variant_option', [ 'option_id' => 'tax_option_id' ]); |
186 | 186 | } |
187 | 187 | } | ... | ... |
common/widgets/views/basket_modal.php
... | ... | @@ -9,13 +9,13 @@ |
9 | 9 | <div class="order_list"> |
10 | 10 | <ul> |
11 | 11 | <?php |
12 | - foreach($items as $item) { | |
12 | + foreach ($items as $item) { | |
13 | 13 | ?> |
14 | 14 | <li> |
15 | - <div class="order_list_li" data-id="<?= $item[ 'item' ]->product_variant_id ?>"> | |
15 | + <div class="order_list_li" data-id="<?= $item[ 'item' ]->id ?>"> | |
16 | 16 | <div class="delete_item_btn"><i class="fa fa-times"></i></div> |
17 | 17 | <div class="little_img"> |
18 | - <?php if(empty( $item[ 'item' ]->product->image )) : ?> | |
18 | + <?php if (empty( $item[ 'item' ]->product->image )) : ?> | |
19 | 19 | <img src="/images/no_photo.png"> |
20 | 20 | <?php else : ?> |
21 | 21 | <img src="/images/<?= $item[ 'item' ]->product->image->image ?>" alt="<?= $item[ 'item' ]->product->image->alt ? $item[ 'item' ]->product->image->alt : $item[ 'item' ]->product->title ?>"> | ... | ... |
console/migrations/m160929_173535_create_product_unit_lang_table.php
... | ... | @@ -13,23 +13,47 @@ |
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - $this->createTable('product_unit_lang', [ | |
17 | - 'product_unit_id' => $this->integer() | |
18 | - ->notNull(), | |
19 | - 'language_id' => $this->integer() | |
20 | - ->notNull(), | |
21 | - 'title' => $this->string() | |
22 | - ->notNull(), | |
23 | - 'short' => $this->string(), | |
24 | - ]); | |
16 | + $this->createTable( | |
17 | + 'product_unit_lang', | |
18 | + [ | |
19 | + 'product_unit_id' => $this->integer() | |
20 | + ->notNull(), | |
21 | + 'language_id' => $this->integer() | |
22 | + ->notNull(), | |
23 | + 'title' => $this->string() | |
24 | + ->notNull(), | |
25 | + 'short' => $this->string(), | |
26 | + ] | |
27 | + ); | |
25 | 28 | |
26 | - $this->createIndex('product_unit_lang_product_unit_language_key', 'product_unit_lang', [ | |
29 | + $this->createIndex( | |
30 | + 'product_unit_lang_product_unit_language_key', | |
31 | + 'product_unit_lang', | |
32 | + [ | |
33 | + 'product_unit_id', | |
34 | + 'language_id', | |
35 | + ], | |
36 | + true | |
37 | + ); | |
38 | + | |
39 | + $this->addForeignKey( | |
40 | + 'product_unit_fk', | |
41 | + 'product_unit_lang', | |
27 | 42 | 'product_unit_id', |
43 | + 'product_unit', | |
44 | + 'id', | |
45 | + 'CASCADE', | |
46 | + 'CASCADE' | |
47 | + ); | |
48 | + $this->addForeignKey( | |
49 | + 'language_fk', | |
50 | + 'product_unit_lang', | |
28 | 51 | 'language_id', |
29 | - ], true); | |
30 | - | |
31 | - $this->addForeignKey('product_unit_fk', 'product_unit_lang', 'product_unit_id', 'product_unit', 'product_unit_id', 'CASCADE', 'CASCADE'); | |
32 | - $this->addForeignKey('language_fk', 'product_unit_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE'); | |
52 | + 'language', | |
53 | + 'id', | |
54 | + 'RESTRICT', | |
55 | + 'CASCADE' | |
56 | + ); | |
33 | 57 | } |
34 | 58 | |
35 | 59 | /** | ... | ... |
console/migrations/m160929_175821_create_product_variant_lang_table.php
... | ... | @@ -13,21 +13,45 @@ |
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - $this->createTable('product_variant_lang', [ | |
17 | - 'product_variant_id' => $this->integer() | |
18 | - ->notNull(), | |
19 | - 'language_id' => $this->integer() | |
20 | - ->notNull(), | |
21 | - 'title' => $this->string() | |
22 | - ->notNull(), | |
23 | - ]); | |
24 | - $this->createIndex('product_variant_lang_product_variant_language_key', 'product_variant_lang', [ | |
16 | + $this->createTable( | |
17 | + 'product_variant_lang', | |
18 | + [ | |
19 | + 'product_variant_id' => $this->integer() | |
20 | + ->notNull(), | |
21 | + 'language_id' => $this->integer() | |
22 | + ->notNull(), | |
23 | + 'title' => $this->string() | |
24 | + ->notNull(), | |
25 | + ] | |
26 | + ); | |
27 | + $this->createIndex( | |
28 | + 'product_variant_lang_product_variant_language_key', | |
29 | + 'product_variant_lang', | |
30 | + [ | |
31 | + 'product_variant_id', | |
32 | + 'language_id', | |
33 | + ], | |
34 | + true | |
35 | + ); | |
36 | + | |
37 | + $this->addForeignKey( | |
38 | + 'product_variant_fk', | |
39 | + 'product_variant_lang', | |
25 | 40 | 'product_variant_id', |
41 | + 'product_variant', | |
42 | + 'id', | |
43 | + 'CASCADE', | |
44 | + 'CASCADE' | |
45 | + ); | |
46 | + $this->addForeignKey( | |
47 | + 'language_fk', | |
48 | + 'product_variant_lang', | |
26 | 49 | 'language_id', |
27 | - ], true); | |
28 | - | |
29 | - $this->addForeignKey('product_variant_fk', 'product_variant_lang', 'product_variant_id', 'product_variant', 'product_variant_id', 'CASCADE', 'CASCADE'); | |
30 | - $this->addForeignKey('language_fk', 'product_variant_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE'); | |
50 | + 'language', | |
51 | + 'id', | |
52 | + 'RESTRICT', | |
53 | + 'CASCADE' | |
54 | + ); | |
31 | 55 | } |
32 | 56 | |
33 | 57 | /** | ... | ... |
console/migrations/m160930_100954_create_seo_lang_table.php
... | ... | @@ -13,58 +13,114 @@ |
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - $this->createTable('seo_lang', [ | |
17 | - 'seo_id' => $this->integer() | |
18 | - ->notNull(), | |
19 | - 'language_id' => $this->integer() | |
20 | - ->notNull(), | |
21 | - 'title' => $this->string(), | |
22 | - 'meta_description' => $this->text(), | |
23 | - 'h1' => $this->string(), | |
24 | - 'meta' => $this->string(), | |
25 | - 'seo_text' => $this->text(), | |
26 | - ]); | |
27 | - $this->createIndex('seo_lang_seo_language_key', 'seo_lang', [ | |
28 | - 'seo_id', | |
29 | - 'language_id', | |
30 | - ], true); | |
16 | + $this->createTable( | |
17 | + 'seo_lang', | |
18 | + [ | |
19 | + 'seo_id' => $this->integer() | |
20 | + ->notNull(), | |
21 | + 'language_id' => $this->integer() | |
22 | + ->notNull(), | |
23 | + 'title' => $this->string(), | |
24 | + 'meta_description' => $this->text(), | |
25 | + 'h1' => $this->string(), | |
26 | + 'meta' => $this->string(), | |
27 | + 'seo_text' => $this->text(), | |
28 | + ] | |
29 | + ); | |
30 | + $this->createIndex( | |
31 | + 'seo_lang_seo_language_key', | |
32 | + 'seo_lang', | |
33 | + [ | |
34 | + 'seo_id', | |
35 | + 'language_id', | |
36 | + ], | |
37 | + true | |
38 | + ); | |
31 | 39 | |
32 | - $this->addForeignKey('seo_fk', 'seo_lang', 'seo_id', 'seo', 'seo_id', 'CASCADE', 'CASCADE'); | |
40 | + $this->addForeignKey('seo_fk', 'seo_lang', 'seo_id', 'seo', 'id', 'CASCADE', 'CASCADE'); | |
33 | 41 | $this->addForeignKey('language_fk', 'seo_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE'); |
34 | - $this->createTable('seo_category_lang', [ | |
35 | - 'seo_category_id' => $this->integer() | |
36 | - ->notNull(), | |
37 | - 'language_id' => $this->integer() | |
38 | - ->notNull(), | |
39 | - 'title' => $this->string(), | |
40 | - ]); | |
41 | - $this->createIndex('seo_category_lang_seo_category_language_key', 'seo_category_lang', [ | |
42 | + $this->createTable( | |
43 | + 'seo_category_lang', | |
44 | + [ | |
45 | + 'seo_category_id' => $this->integer() | |
46 | + ->notNull(), | |
47 | + 'language_id' => $this->integer() | |
48 | + ->notNull(), | |
49 | + 'title' => $this->string(), | |
50 | + ] | |
51 | + ); | |
52 | + $this->createIndex( | |
53 | + 'seo_category_lang_seo_category_language_key', | |
54 | + 'seo_category_lang', | |
55 | + [ | |
56 | + 'seo_category_id', | |
57 | + 'language_id', | |
58 | + ], | |
59 | + true | |
60 | + ); | |
61 | + | |
62 | + $this->addForeignKey( | |
63 | + 'seo_category_fk', | |
64 | + 'seo_category_lang', | |
42 | 65 | 'seo_category_id', |
66 | + 'seo_category', | |
67 | + 'id', | |
68 | + 'CASCADE', | |
69 | + 'CASCADE' | |
70 | + ); | |
71 | + $this->addForeignKey( | |
72 | + 'language_fk', | |
73 | + 'seo_category_lang', | |
43 | 74 | 'language_id', |
44 | - ], true); | |
75 | + 'language', | |
76 | + 'id', | |
77 | + 'RESTRICT', | |
78 | + 'CASCADE' | |
79 | + ); | |
80 | + $this->createTable( | |
81 | + 'seo_dynamic_lang', | |
82 | + [ | |
83 | + 'seo_dynamic_id' => $this->integer() | |
84 | + ->notNull(), | |
85 | + 'language_id' => $this->integer() | |
86 | + ->notNull(), | |
87 | + 'title' => $this->string(), | |
88 | + 'meta_title' => $this->text(), | |
89 | + 'h1' => $this->string(), | |
90 | + 'key' => $this->string(), | |
91 | + 'meta' => $this->string(), | |
92 | + 'meta_description' => $this->text(), | |
93 | + 'seo_text' => $this->text(), | |
94 | + ] | |
95 | + ); | |
96 | + $this->createIndex( | |
97 | + 'seo_dynamic_lang_seo_dynamic_language_key', | |
98 | + 'seo_dynamic_lang', | |
99 | + [ | |
100 | + 'seo_dynamic_id', | |
101 | + 'language_id', | |
102 | + ], | |
103 | + true | |
104 | + ); | |
45 | 105 | |
46 | - $this->addForeignKey('seo_category_fk', 'seo_category_lang', 'seo_category_id', 'seo_category', 'seo_category_id', 'CASCADE', 'CASCADE'); | |
47 | - $this->addForeignKey('language_fk', 'seo_category_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE'); | |
48 | - $this->createTable('seo_dynamic_lang', [ | |
49 | - 'seo_dynamic_id' => $this->integer() | |
50 | - ->notNull(), | |
51 | - 'language_id' => $this->integer() | |
52 | - ->notNull(), | |
53 | - 'title' => $this->string(), | |
54 | - 'meta_title' => $this->text(), | |
55 | - 'h1' => $this->string(), | |
56 | - 'key' => $this->string(), | |
57 | - 'meta' => $this->string(), | |
58 | - 'meta_description' => $this->text(), | |
59 | - 'seo_text' => $this->text(), | |
60 | - ]); | |
61 | - $this->createIndex('seo_dynamic_lang_seo_dynamic_language_key', 'seo_dynamic_lang', [ | |
106 | + $this->addForeignKey( | |
107 | + 'seo_dynamic_fk', | |
108 | + 'seo_dynamic_lang', | |
62 | 109 | 'seo_dynamic_id', |
110 | + 'seo_dynamic', | |
111 | + 'id', | |
112 | + 'CASCADE', | |
113 | + 'CASCADE' | |
114 | + ); | |
115 | + $this->addForeignKey( | |
116 | + 'language_fk', | |
117 | + 'seo_dynamic_lang', | |
63 | 118 | 'language_id', |
64 | - ], true); | |
65 | - | |
66 | - $this->addForeignKey('seo_dynamic_fk', 'seo_dynamic_lang', 'seo_dynamic_id', 'seo_dynamic', 'seo_dynamic_id', 'CASCADE', 'CASCADE'); | |
67 | - $this->addForeignKey('language_fk', 'seo_dynamic_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE'); | |
119 | + 'language', | |
120 | + 'id', | |
121 | + 'RESTRICT', | |
122 | + 'CASCADE' | |
123 | + ); | |
68 | 124 | } |
69 | 125 | |
70 | 126 | /** | ... | ... |
console/migrations/m160930_133757_create_service_lang_table.php
... | ... | @@ -13,26 +13,34 @@ |
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - $this->createTable('service_lang', [ | |
17 | - 'service_id' => $this->integer() | |
18 | - ->notNull(), | |
19 | - 'language_id' => $this->integer() | |
20 | - ->notNull(), | |
21 | - 'title' => $this->string() | |
22 | - ->notNull(), | |
23 | - 'body' => $this->text() | |
24 | - ->notNull(), | |
25 | - 'seo_text' => $this->text(), | |
26 | - 'meta_title' => $this->string(), | |
27 | - 'meta_description' => $this->string(), | |
28 | - 'h1' => $this->string(), | |
29 | - ]); | |
30 | - $this->createIndex('service_lang_service_language_key', 'service_lang', [ | |
31 | - 'service_id', | |
32 | - 'language_id', | |
33 | - ], true); | |
16 | + $this->createTable( | |
17 | + 'service_lang', | |
18 | + [ | |
19 | + 'service_id' => $this->integer() | |
20 | + ->notNull(), | |
21 | + 'language_id' => $this->integer() | |
22 | + ->notNull(), | |
23 | + 'title' => $this->string() | |
24 | + ->notNull(), | |
25 | + 'body' => $this->text() | |
26 | + ->notNull(), | |
27 | + 'seo_text' => $this->text(), | |
28 | + 'meta_title' => $this->string(), | |
29 | + 'meta_description' => $this->string(), | |
30 | + 'h1' => $this->string(), | |
31 | + ] | |
32 | + ); | |
33 | + $this->createIndex( | |
34 | + 'service_lang_service_language_key', | |
35 | + 'service_lang', | |
36 | + [ | |
37 | + 'service_id', | |
38 | + 'language_id', | |
39 | + ], | |
40 | + true | |
41 | + ); | |
34 | 42 | |
35 | - $this->addForeignKey('service_fk', 'service_lang', 'service_id', 'service', 'service_id', 'CASCADE', 'CASCADE'); | |
43 | + $this->addForeignKey('service_fk', 'service_lang', 'service_id', 'service', 'id', 'CASCADE', 'CASCADE'); | |
36 | 44 | $this->addForeignKey('language_fk', 'service_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE'); |
37 | 45 | } |
38 | 46 | ... | ... |
console/migrations/m160930_142752_create_slider_image_lang_table.php
... | ... | @@ -13,21 +13,45 @@ |
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - $this->createTable('slider_image_lang', [ | |
17 | - 'slider_image_id' => $this->integer() | |
18 | - ->notNull(), | |
19 | - 'language_id' => $this->integer() | |
20 | - ->notNull(), | |
21 | - 'title' => $this->string(), | |
22 | - 'alt' => $this->string(), | |
23 | - ]); | |
24 | - $this->createIndex('slider_image_lang_slider_image_language_key', 'slider_image_lang', [ | |
16 | + $this->createTable( | |
17 | + 'slider_image_lang', | |
18 | + [ | |
19 | + 'slider_image_id' => $this->integer() | |
20 | + ->notNull(), | |
21 | + 'language_id' => $this->integer() | |
22 | + ->notNull(), | |
23 | + 'title' => $this->string(), | |
24 | + 'alt' => $this->string(), | |
25 | + ] | |
26 | + ); | |
27 | + $this->createIndex( | |
28 | + 'slider_image_lang_slider_image_language_key', | |
29 | + 'slider_image_lang', | |
30 | + [ | |
31 | + 'slider_image_id', | |
32 | + 'language_id', | |
33 | + ], | |
34 | + true | |
35 | + ); | |
36 | + | |
37 | + $this->addForeignKey( | |
38 | + 'slider_image_fk', | |
39 | + 'slider_image_lang', | |
25 | 40 | 'slider_image_id', |
41 | + 'slider_image', | |
42 | + 'id', | |
43 | + 'CASCADE', | |
44 | + 'CASCADE' | |
45 | + ); | |
46 | + $this->addForeignKey( | |
47 | + 'language_fk', | |
48 | + 'slider_image_lang', | |
26 | 49 | 'language_id', |
27 | - ], true); | |
28 | - | |
29 | - $this->addForeignKey('slider_image_fk', 'slider_image_lang', 'slider_image_id', 'slider_image', 'slider_image_id', 'CASCADE', 'CASCADE'); | |
30 | - $this->addForeignKey('language_fk', 'slider_image_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE'); | |
50 | + 'language', | |
51 | + 'id', | |
52 | + 'RESTRICT', | |
53 | + 'CASCADE' | |
54 | + ); | |
31 | 55 | } |
32 | 56 | |
33 | 57 | /** | ... | ... |
console/migrations/m161011_104931_create_stock_lang_table.php
1 | 1 | <?php |
2 | - | |
3 | -use yii\db\Migration; | |
4 | - | |
5 | -/** | |
6 | - * Handles the creation for table `stock_lang`. | |
7 | - */ | |
8 | -class m161011_104931_create_stock_lang_table extends Migration | |
9 | -{ | |
2 | + | |
3 | + use yii\db\Migration; | |
4 | + | |
10 | 5 | /** |
11 | - * @inheritdoc | |
6 | + * Handles the creation for table `stock_lang`. | |
12 | 7 | */ |
13 | - public function up() | |
8 | + class m161011_104931_create_stock_lang_table extends Migration | |
14 | 9 | { |
15 | - $this->createTable('stock_lang', [ | |
16 | - 'stock_id' => $this->integer() | |
17 | - ->notNull(), | |
18 | - 'language_id' => $this->integer() | |
19 | - ->notNull(), | |
20 | - 'title' => $this->string() | |
21 | - ->notNull(), | |
22 | - ]); | |
23 | - $this->createIndex('stock_lang_stock_language_key', 'stock_lang', [ | |
24 | - 'stock_id', | |
25 | - 'language_id', | |
26 | - ], true); | |
10 | + /** | |
11 | + * @inheritdoc | |
12 | + */ | |
13 | + public function up() | |
14 | + { | |
15 | + $this->createTable( | |
16 | + 'stock_lang', | |
17 | + [ | |
18 | + 'stock_id' => $this->integer() | |
19 | + ->notNull(), | |
20 | + 'language_id' => $this->integer() | |
21 | + ->notNull(), | |
22 | + 'title' => $this->string() | |
23 | + ->notNull(), | |
24 | + ] | |
25 | + ); | |
26 | + $this->createIndex( | |
27 | + 'stock_lang_stock_language_key', | |
28 | + 'stock_lang', | |
29 | + [ | |
30 | + 'stock_id', | |
31 | + 'language_id', | |
32 | + ], | |
33 | + true | |
34 | + ); | |
35 | + | |
36 | + $this->addForeignKey('stock_fk', 'stock_lang', 'stock_id', 'stock', 'id', 'CASCADE', 'CASCADE'); | |
37 | + $this->addForeignKey('language_fk', 'stock_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE'); | |
38 | + } | |
27 | 39 | |
28 | - $this->addForeignKey('stock_fk', 'stock_lang', 'stock_id', 'stock', 'stock_id', 'CASCADE', 'CASCADE'); | |
29 | - $this->addForeignKey('language_fk', 'stock_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE'); | |
40 | + /** | |
41 | + * @inheritdoc | |
42 | + */ | |
43 | + public function down() | |
44 | + { | |
45 | + $this->dropTable('stock_lang'); | |
46 | + } | |
30 | 47 | } |
31 | - | |
32 | - /** | |
33 | - * @inheritdoc | |
34 | - */ | |
35 | - public function down() | |
36 | - { | |
37 | - $this->dropTable('stock_lang'); | |
38 | - } | |
39 | -} | ... | ... |
frontend/web/js/artbox_basket.js
1 | -var ArtboxBasket = (function () { | |
1 | +var ArtboxBasket = (function() { | |
2 | 2 | function ArtboxBasket() { |
3 | 3 | this.init(true, true); |
4 | 4 | } |
5 | - Object.defineProperty(ArtboxBasket.prototype, "items", { | |
6 | - get: function () { | |
7 | - return this._items; | |
8 | - }, | |
9 | - enumerable: true, | |
10 | - configurable: true | |
11 | - }); | |
12 | - ArtboxBasket.prototype.init = function (update_modal, update_cart) { | |
13 | - $.get('/basket', function (data) { | |
14 | - this._items = data.basket; | |
15 | - if (update_modal) { | |
16 | - this.updateModal(data.modal, false); | |
17 | - } | |
18 | - if (update_cart) { | |
19 | - this.updateCart(data.cart); | |
20 | - } | |
21 | - }.bind(this), 'json').fail(function () { | |
22 | - console.error('Basket cannot be init'); | |
23 | - }); | |
5 | + | |
6 | + Object.defineProperty( | |
7 | + ArtboxBasket.prototype, "items", { | |
8 | + get: function() { | |
9 | + return this._items; | |
10 | + }, | |
11 | + enumerable: true, | |
12 | + configurable: true | |
13 | + } | |
14 | + ); | |
15 | + ArtboxBasket.prototype.init = function(update_modal, update_cart) { | |
16 | + $.get( | |
17 | + '/basket', function(data) { | |
18 | + this._items = data.basket; | |
19 | + if (update_modal) { | |
20 | + this.updateModal(data.modal, false); | |
21 | + } | |
22 | + if (update_cart) { | |
23 | + this.updateCart(data.cart); | |
24 | + } | |
25 | + }.bind(this), 'json' | |
26 | + ) | |
27 | + .fail( | |
28 | + function() { | |
29 | + console.error('Basket cannot be init'); | |
30 | + } | |
31 | + ); | |
24 | 32 | }; |
25 | - ArtboxBasket.prototype.add = function (product_variant_id) { | |
26 | - $.post('/basket/add?product_variant_id=' + product_variant_id, function (data) { | |
27 | - this._items = data.basket; | |
28 | - this.updateModal(data.modal, data.cart, true); | |
29 | - showForm(); | |
30 | - }.bind(this), 'json').fail(function (xhr, status, error) { | |
31 | - console.error(error); | |
32 | - }); | |
33 | + ArtboxBasket.prototype.add = function(product_variant_id) { | |
34 | + $.post( | |
35 | + '/basket/add?product_variant_id=' + product_variant_id, function(data) { | |
36 | + this._items = data.basket; | |
37 | + this.updateModal(data.modal, data.cart, true); | |
38 | + showForm(); | |
39 | + }.bind(this), 'json' | |
40 | + ) | |
41 | + .fail( | |
42 | + function(xhr, status, error) { | |
43 | + console.error(error); | |
44 | + } | |
45 | + ); | |
33 | 46 | }; |
34 | - ArtboxBasket.prototype.remove = function (product_variant_id) { | |
35 | - $.post('/basket/remove?product_variant_id=' + product_variant_id, function (data) { | |
36 | - this._items = data.basket; | |
37 | - this.updateCart(data.cart); | |
38 | - // this.updateModal(data.modal, data.cart, true); | |
39 | - }.bind(this), 'json').fail(function (xhr, status, error) { | |
40 | - console.error(error); | |
41 | - }); | |
47 | + ArtboxBasket.prototype.remove = function(product_variant_id) { | |
48 | + $.post( | |
49 | + '/basket/remove?product_variant_id=' + product_variant_id, function(data) { | |
50 | + this._items = data.basket; | |
51 | + this.updateCart(data.cart); | |
52 | + // this.updateModal(data.modal, data.cart, true); | |
53 | + }.bind(this), 'json' | |
54 | + ) | |
55 | + .fail( | |
56 | + function(xhr, status, error) { | |
57 | + console.error(error); | |
58 | + } | |
59 | + ); | |
42 | 60 | }; |
43 | - ArtboxBasket.prototype.updateModal = function (modal, cart_html, show) { | |
44 | - if (show === void 0) { show = false; } | |
61 | + ArtboxBasket.prototype.updateModal = function(modal, cart_html, show) { | |
62 | + if (show === void 0) { | |
63 | + show = false; | |
64 | + } | |
45 | 65 | var modalBox = $('#modal_form-2'); |
46 | 66 | modalBox.html(modal); |
47 | 67 | if (cart_html) { |
48 | 68 | this.updateCart(cart_html); |
49 | 69 | } |
50 | 70 | }; |
51 | - ArtboxBasket.prototype.updateCart = function (cart_html) { | |
71 | + ArtboxBasket.prototype.updateCart = function(cart_html) { | |
52 | 72 | var cart = $('.question-form '); |
53 | 73 | cart.html(cart_html); |
54 | 74 | }; |
55 | - Object.defineProperty(ArtboxBasket.prototype, "count", { | |
56 | - get: function () { | |
57 | - return Object.keys(this._items).length; | |
58 | - }, | |
59 | - enumerable: true, | |
60 | - configurable: true | |
61 | - }); | |
75 | + Object.defineProperty( | |
76 | + ArtboxBasket.prototype, "count", { | |
77 | + get: function() { | |
78 | + return Object.keys(this._items).length; | |
79 | + }, | |
80 | + enumerable: true, | |
81 | + configurable: true | |
82 | + } | |
83 | + ); | |
62 | 84 | return ArtboxBasket; |
63 | 85 | }()); |
64 | 86 | //# sourceMappingURL=artbox_basket.js.map |
65 | 87 | \ No newline at end of file | ... | ... |