Commit 77d77c349083369bb574b2b59ee4808a40e2a465
1 parent
a6ba0937
stock
Showing
16 changed files
with
843 additions
and
668 deletions
Show diff stats
assets/StockAsset.php
controllers/ShopController.php
1 | 1 | <?php |
2 | - | |
3 | -namespace artbox\stock\controllers; | |
4 | - | |
5 | -use Yii; | |
6 | -use artbox\stock\models\Shop; | |
7 | -use yii\data\ActiveDataProvider; | |
8 | -use yii\helpers\VarDumper; | |
9 | -use yii\web\Controller; | |
10 | -use yii\web\NotFoundHttpException; | |
11 | -use yii\filters\VerbFilter; | |
12 | -use yii\filters\AccessControl; | |
13 | -/** | |
14 | - * ShopController implements the CRUD actions for Shop model. | |
15 | - */ | |
16 | -class ShopController extends Controller | |
17 | -{ | |
2 | + | |
3 | + namespace artbox\stock\controllers; | |
4 | + | |
5 | + use artbox\stock\models\Shop; | |
6 | + use yii\data\ActiveDataProvider; | |
7 | + use yii\web\Controller; | |
8 | + use yii\web\NotFoundHttpException; | |
9 | + use yii\filters\VerbFilter; | |
10 | + use yii\filters\AccessControl; | |
11 | + | |
18 | 12 | /** |
19 | - * @inheritdoc | |
13 | + * ShopController implements the CRUD actions for Shop model. | |
20 | 14 | */ |
21 | - public function getViewPath() | |
15 | + class ShopController extends Controller | |
22 | 16 | { |
23 | - return '@artbox/stock/views/shop'; | |
24 | - } | |
25 | - public function behaviors() | |
26 | - { | |
27 | - return [ | |
28 | - 'access' => [ | |
29 | - 'class' => AccessControl::className(), | |
30 | - 'rules' => [ | |
31 | - [ | |
32 | - 'actions' => [ | |
33 | - 'login', | |
34 | - 'error', | |
17 | + /** | |
18 | + * @inheritdoc | |
19 | + */ | |
20 | + public function getViewPath() | |
21 | + { | |
22 | + return '@artbox/stock/views/shop'; | |
23 | + } | |
24 | + public function behaviors() | |
25 | + { | |
26 | + return [ | |
27 | + 'access' => [ | |
28 | + 'class' => AccessControl::className(), | |
29 | + 'rules' => [ | |
30 | + [ | |
31 | + 'actions' => [ | |
32 | + 'login', | |
33 | + 'error', | |
34 | + ], | |
35 | + 'allow' => true, | |
36 | + ], | |
37 | + [ | |
38 | + 'allow' => true, | |
39 | + 'roles' => [ '@' ], | |
35 | 40 | ], |
36 | - 'allow' => true, | |
37 | - ], | |
38 | - [ | |
39 | - 'allow' => true, | |
40 | - 'roles' => [ '@' ], | |
41 | 41 | ], |
42 | 42 | ], |
43 | - ], | |
44 | - 'verbs' => [ | |
45 | - 'class' => VerbFilter::className(), | |
46 | - 'actions' => [ | |
47 | - 'delete' => ['POST'], | |
43 | + 'verbs' => [ | |
44 | + 'class' => VerbFilter::className(), | |
45 | + 'actions' => [ | |
46 | + 'delete' => [ 'POST' ], | |
47 | + ], | |
48 | 48 | ], |
49 | - ], | |
50 | - ]; | |
51 | - } | |
52 | - | |
53 | - /** | |
54 | - * Lists all Shop models. | |
55 | - * @return mixed | |
56 | - */ | |
57 | - public function actionIndex() | |
58 | - { | |
59 | - $dataProvider = new ActiveDataProvider([ | |
60 | - 'query' => Shop::find(), | |
61 | - ]); | |
62 | - | |
63 | - return $this->render('index', [ | |
64 | - 'dataProvider' => $dataProvider, | |
65 | - ]); | |
66 | - } | |
67 | - | |
68 | - /** | |
69 | - * Displays a single Shop model. | |
70 | - * @param integer $id | |
71 | - * @return mixed | |
72 | - */ | |
73 | - public function actionView($id) | |
74 | - { | |
75 | - return $this->render('view', [ | |
76 | - 'model' => $this->findModel($id), | |
77 | - ]); | |
78 | - } | |
79 | - | |
80 | - /** | |
81 | - * Creates a new Shop model. | |
82 | - * If creation is successful, the browser will be redirected to the 'view' page. | |
83 | - * @return mixed | |
84 | - */ | |
85 | - public function actionCreate() | |
86 | - { | |
87 | - $model = new Shop(); | |
88 | - $model->generateLangs(); | |
89 | - $model->getCities(); | |
90 | - if ($model->loadWithLangs(\Yii::$app->request) && $model->saveWithLangs()) { | |
91 | - return $this->redirect( | |
49 | + ]; | |
50 | + } | |
51 | + | |
52 | + /** | |
53 | + * Lists all Shop models. | |
54 | + * | |
55 | + * @return mixed | |
56 | + */ | |
57 | + public function actionIndex() | |
58 | + { | |
59 | + $dataProvider = new ActiveDataProvider( | |
60 | + [ | |
61 | + 'query' => Shop::find(), | |
62 | + ] | |
63 | + ); | |
64 | + | |
65 | + return $this->render( | |
66 | + 'index', | |
92 | 67 | [ |
93 | - 'view', | |
94 | - 'id' => $model->id, | |
68 | + 'dataProvider' => $dataProvider, | |
95 | 69 | ] |
96 | 70 | ); |
97 | 71 | } |
98 | - return $this->render( | |
99 | - 'create', | |
100 | - [ | |
101 | - 'model' => $model, | |
102 | - 'modelLangs' => $model->modelLangs, | |
103 | - ] | |
104 | - ); | |
105 | - | |
106 | - } | |
107 | - | |
108 | - /** | |
109 | - * Updates an existing Shop model. | |
110 | - * If update is successful, the browser will be redirected to the 'view' page. | |
111 | - * @param integer $id | |
112 | - * @return mixed | |
113 | - */ | |
114 | - public function actionUpdate($id) | |
115 | - { | |
116 | - $model = $this->findModel($id); | |
117 | - $model->generateLangs(); | |
118 | - $model->getCities(); | |
119 | - $model->loadWithLangs(\Yii::$app->request); | |
120 | - //print_r(\Yii::$app->request); | |
121 | - if ($model->loadWithLangs(\Yii::$app->request) && $model->saveWithLangs()) { | |
122 | - return $this->redirect( | |
72 | + | |
73 | + /** | |
74 | + * Displays a single Shop model. | |
75 | + * | |
76 | + * @param integer $id | |
77 | + * | |
78 | + * @return mixed | |
79 | + */ | |
80 | + public function actionView($id) | |
81 | + { | |
82 | + return $this->render( | |
83 | + 'view', | |
123 | 84 | [ |
124 | - 'view', | |
125 | - 'id' => $model->id, | |
85 | + 'model' => $this->findModel($id), | |
126 | 86 | ] |
127 | 87 | ); |
128 | 88 | } |
129 | - return $this->render( | |
130 | - 'update', | |
131 | - [ | |
132 | - 'model' => $model, | |
133 | - 'modelLangs' => $model->modelLangs, | |
134 | - ] | |
135 | - ); | |
136 | - } | |
137 | - | |
138 | - /** | |
139 | - * Deletes an existing Shop model. | |
140 | - * If deletion is successful, the browser will be redirected to the 'index' page. | |
141 | - * @param integer $id | |
142 | - * @return mixed | |
143 | - */ | |
144 | - public function actionDelete($id) | |
145 | - { | |
146 | - $this->findModel($id)->delete(); | |
147 | - | |
148 | - return $this->redirect(['index']); | |
149 | - } | |
150 | - | |
151 | - /** | |
152 | - * Finds the Shop model based on its primary key value. | |
153 | - * If the model is not found, a 404 HTTP exception will be thrown. | |
154 | - * @param integer $id | |
155 | - * @return Shop the loaded model | |
156 | - * @throws NotFoundHttpException if the model cannot be found | |
157 | - */ | |
158 | - protected function findModel($id) | |
159 | - { | |
160 | - if (($model = Shop::findOne($id)) !== null) { | |
161 | - return $model; | |
162 | - } else { | |
163 | - throw new NotFoundHttpException('The requested page does not exist.'); | |
89 | + | |
90 | + /** | |
91 | + * Creates a new Shop model. | |
92 | + * If creation is successful, the browser will be redirected to the 'view' page. | |
93 | + * | |
94 | + * @return mixed | |
95 | + */ | |
96 | + public function actionCreate() | |
97 | + { | |
98 | + $model = new Shop(); | |
99 | + $model->generateLangs(); | |
100 | + $model->getCities(); | |
101 | + if ($model->loadWithLangs(\Yii::$app->request) && $model->saveWithLangs()) { | |
102 | + return $this->redirect( | |
103 | + [ | |
104 | + 'view', | |
105 | + 'id' => $model->id, | |
106 | + ] | |
107 | + ); | |
108 | + } | |
109 | + return $this->render( | |
110 | + 'create', | |
111 | + [ | |
112 | + 'model' => $model, | |
113 | + 'modelLangs' => $model->modelLangs, | |
114 | + ] | |
115 | + ); | |
116 | + | |
117 | + } | |
118 | + | |
119 | + /** | |
120 | + * Updates an existing Shop model. | |
121 | + * If update is successful, the browser will be redirected to the 'view' page. | |
122 | + * | |
123 | + * @param integer $id | |
124 | + * | |
125 | + * @return mixed | |
126 | + */ | |
127 | + public function actionUpdate($id) | |
128 | + { | |
129 | + $model = $this->findModel($id); | |
130 | + $model->generateLangs(); | |
131 | + $model->getCities(); | |
132 | + if ($model->loadWithLangs(\Yii::$app->request) && $model->saveWithLangs()) { | |
133 | + return $this->redirect( | |
134 | + [ | |
135 | + 'view', | |
136 | + 'id' => $model->id, | |
137 | + ] | |
138 | + ); | |
139 | + } | |
140 | + return $this->render( | |
141 | + 'update', | |
142 | + [ | |
143 | + 'model' => $model, | |
144 | + 'modelLangs' => $model->modelLangs, | |
145 | + ] | |
146 | + ); | |
147 | + } | |
148 | + | |
149 | + /** | |
150 | + * Deletes an existing Shop model. | |
151 | + * If deletion is successful, the browser will be redirected to the 'index' page. | |
152 | + * | |
153 | + * @param integer $id | |
154 | + * | |
155 | + * @return mixed | |
156 | + */ | |
157 | + public function actionDelete($id) | |
158 | + { | |
159 | + $this->findModel($id) | |
160 | + ->delete(); | |
161 | + | |
162 | + return $this->redirect([ 'index' ]); | |
163 | + } | |
164 | + | |
165 | + /** | |
166 | + * Finds the Shop model based on its primary key value. | |
167 | + * If the model is not found, a 404 HTTP exception will be thrown. | |
168 | + * | |
169 | + * @param integer $id | |
170 | + * | |
171 | + * @return Shop the loaded model | |
172 | + * @throws NotFoundHttpException if the model cannot be found | |
173 | + */ | |
174 | + protected function findModel($id) | |
175 | + { | |
176 | + if (( $model = Shop::findOne($id) ) !== null) { | |
177 | + return $model; | |
178 | + } else { | |
179 | + throw new NotFoundHttpException('The requested page does not exist.'); | |
180 | + } | |
164 | 181 | } |
165 | 182 | } |
166 | -} | ... | ... |
messages/ru/stock.php
1 | 1 | <?php |
2 | -return [ | |
3 | - 'Cities' => 'ะะพัะพะดะฐ', | |
4 | - 'Shops' => 'ะะฐะณะฐะทะธะฝั/ัะบะปะฐะดั', | |
5 | - 'Title' => 'ะะฐะทะฒะฐะฝะธะต', | |
6 | - 'Sort' => 'ะกะพััะธัะพะฒะบะฐ', | |
7 | - 'Status' => 'ะกัะฐััั', | |
8 | - 'Description' => 'ะะฟะธัะฐะฝะธะต', | |
9 | - 'Create City' => 'ะะพะฑะฐะฒะธัั ะณะพัะพะด', | |
10 | - 'Alias' => 'ะะปะธะฐั', | |
11 | - 'Update' => 'ะะฑะฝะพะฒะธัั', | |
12 | - 'Address' => 'ะะดัะตั', | |
13 | - 'Create Shop' => 'ะะพะฑะฐะฒะธัั ะผะฐะณะฐะทะธะฝ', | |
14 | - 'Mode' => "ะ ะฐัะฟะธัะฐะฝะธะต ัะฐะฑะพัั", | |
15 | - 'Delete' => 'ะฃะดะฐะปะธัั', | |
16 | - 'Create' => "ะะพะฑะฐะฒะธัั", | |
17 | -] | |
2 | + return [ | |
3 | + 'Cities' => 'ะะพัะพะดะฐ', | |
4 | + 'Shops' => 'ะะฐะณะฐะทะธะฝั/ัะบะปะฐะดั', | |
5 | + 'Title' => 'ะะฐะทะฒะฐะฝะธะต', | |
6 | + 'Sort' => 'ะกะพััะธัะพะฒะบะฐ', | |
7 | + 'Status' => 'ะกัะฐััั', | |
8 | + 'Description' => 'ะะฟะธัะฐะฝะธะต', | |
9 | + 'Create City' => 'ะะพะฑะฐะฒะธัั ะณะพัะพะด', | |
10 | + 'Alias' => 'ะะปะธะฐั', | |
11 | + 'Update' => 'ะะฑะฝะพะฒะธัั', | |
12 | + 'Address' => 'ะะดัะตั', | |
13 | + 'Create Shop' => 'ะะพะฑะฐะฒะธัั ะผะฐะณะฐะทะธะฝ', | |
14 | + 'Mode' => "ะ ะฐัะฟะธัะฐะฝะธะต ัะฐะฑะพัั", | |
15 | + 'Delete' => 'ะฃะดะฐะปะธัั', | |
16 | + 'Create' => "ะะพะฑะฐะฒะธัั", | |
17 | + 'Mon' => 'ะะฝ', | |
18 | + 'Tue' => 'ะั', | |
19 | + 'Wed' => 'ะกั', | |
20 | + 'Thu' => 'ะงั', | |
21 | + 'Fri' => 'ะั', | |
22 | + 'Sat' => 'ะกะฑ', | |
23 | + 'Sun' => 'ะั', | |
24 | + ] | |
18 | 25 | ?> |
19 | 26 | \ No newline at end of file | ... | ... |
models/Shop.php
1 | 1 | <?php |
2 | - | |
3 | -namespace artbox\stock\models; | |
4 | - | |
5 | -use Yii; | |
6 | -use artbox\core\models\Language; | |
7 | -use artbox\core\behaviors\LanguageBehavior; | |
8 | -use yii\helpers\Json; | |
9 | - | |
10 | -/** | |
11 | - * This is the model class for table "shop". | |
12 | - * | |
13 | - * @property integer $id | |
14 | - * @property string $mode | |
15 | - * @property integer $city_id | |
16 | - * @property integer $sort | |
17 | - * @property boolean $status | |
18 | - * | |
19 | - * @property City $city | |
20 | - * @property ShopLang[] $shopLangs | |
21 | - * @property Language[] $languages | |
22 | - */ | |
23 | -class Shop extends \yii\db\ActiveRecord | |
24 | -{ | |
2 | + | |
3 | + namespace artbox\stock\models; | |
4 | + | |
5 | + use artbox\core\models\Language; | |
6 | + use artbox\core\behaviors\LanguageBehavior; | |
7 | + use yii\helpers\Json; | |
8 | + use yii\web\Request; | |
9 | + use yii\db\ActiveRecord; | |
25 | 10 | /** |
26 | - * @inheritdoc | |
11 | + * This is the model class for table "shop". | |
12 | + * | |
13 | + * @property integer $id | |
14 | + * @property string $mode | |
15 | + * @property integer $city_id | |
16 | + * @property integer $sort | |
17 | + * @property boolean $status | |
18 | + * @property City $city | |
19 | + * @property ShopLang[] $shopLangs | |
20 | + * @property Language[] $languages | |
21 | + * @property ShopLang[] $modelLangs | |
22 | + * | |
23 | + * @method bool saveWithLangs() | |
24 | + * @method bool loadWithLangs( Request $request) | |
25 | + * @method void generateLangs() | |
27 | 26 | */ |
28 | - public $cities = []; | |
29 | - public static function tableName() | |
27 | + class Shop extends ActiveRecord | |
30 | 28 | { |
31 | - return 'shop'; | |
32 | - } | |
33 | - public function behaviors() | |
34 | - { | |
35 | - return [ | |
36 | - 'language' => [ | |
37 | - 'class' => LanguageBehavior::className(), | |
38 | - ], | |
39 | - ]; | |
40 | - } | |
41 | - /** | |
42 | - * @inheritdoc | |
43 | - */ | |
44 | - public function rules() | |
45 | - { | |
46 | - return [ | |
47 | - [['city_id', 'sort'], 'integer'], | |
48 | - [['status'], 'boolean'], | |
49 | - [['mode', 'modeStr'], 'safe'], | |
50 | - [['coords', 'coordsArr'], 'safe'], | |
51 | - [['city_id'], 'exist', 'skipOnError' => true, 'targetClass' => City::className(), 'targetAttribute' => ['city_id' => 'id']], | |
52 | - ]; | |
53 | - } | |
54 | - | |
55 | - /** | |
56 | - * @inheritdoc | |
57 | - */ | |
58 | - public function attributeLabels() | |
59 | - { | |
60 | - return [ | |
61 | - 'id' => 'ID', | |
62 | - 'mode' => \Yii::t('stock', 'Mode'), | |
63 | - 'city_id' => 'City ID', | |
64 | - 'sort' => \Yii::t('stock', 'Sort'), | |
65 | - 'status' => \Yii::t('stock', 'Status'), | |
66 | - ]; | |
67 | - } | |
68 | - | |
69 | - /** | |
70 | - * @return \yii\db\ActiveQuery | |
71 | - */ | |
72 | - public function getCity() | |
73 | - { | |
74 | - return $this->hasOne(City::className(), ['id' => 'city_id']); | |
75 | - } | |
76 | - | |
77 | - public function getCities(){ | |
78 | - $cities = City::find()->with(['lang'])->all(); | |
79 | - foreach($cities as $city){ | |
80 | - $this->cities[$city->id] = $city->lang->title; | |
29 | + /** | |
30 | + * @inheritdoc | |
31 | + */ | |
32 | + public $cities = []; | |
33 | + public static function tableName() | |
34 | + { | |
35 | + return 'shop'; | |
81 | 36 | } |
82 | - | |
83 | - } | |
84 | - | |
85 | - /** | |
86 | - * @return \yii\db\ActiveQuery | |
87 | - */ | |
88 | - public function getShopLangs() | |
89 | - { | |
90 | - return $this->hasMany(ShopLang::className(), ['shop_id' => 'id']); | |
91 | - } | |
92 | - | |
93 | - /** | |
94 | - * @return \yii\db\ActiveQuery | |
95 | - */ | |
96 | - public function getLanguages() | |
97 | - { | |
98 | - return $this->hasMany(Language::className(), ['id' => 'language_id'])->viaTable('shop_lang', ['shop_id' => 'id']); | |
99 | - } | |
100 | - | |
101 | - public function setModeStr($value){ | |
102 | - $this->mode = Json::encode($value); | |
103 | - } | |
104 | - | |
105 | - public function getModeStr(){ | |
106 | - return Json::decode($this->mode); | |
107 | - } | |
108 | - | |
109 | - public function setCoordsArr($value){ | |
110 | - $this->coords = Json::encode($value); | |
111 | - } | |
112 | - | |
113 | - public function getCoordsArr(){ | |
114 | - return Json::decode($this->coords); | |
37 | + public function behaviors() | |
38 | + { | |
39 | + return [ | |
40 | + 'language' => [ | |
41 | + 'class' => LanguageBehavior::className(), | |
42 | + ], | |
43 | + ]; | |
44 | + } | |
45 | + /** | |
46 | + * @inheritdoc | |
47 | + */ | |
48 | + public function rules() | |
49 | + { | |
50 | + return [ | |
51 | + [ | |
52 | + [ | |
53 | + 'city_id', | |
54 | + 'sort', | |
55 | + ], | |
56 | + 'integer', | |
57 | + ], | |
58 | + [ | |
59 | + [ 'status' ], | |
60 | + 'boolean', | |
61 | + ], | |
62 | + [ | |
63 | + [ | |
64 | + 'mode', | |
65 | + 'modeStr', | |
66 | + ], | |
67 | + 'safe', | |
68 | + ], | |
69 | + [ | |
70 | + [ | |
71 | + 'coords', | |
72 | + 'coordsArr', | |
73 | + ], | |
74 | + 'safe', | |
75 | + ], | |
76 | + [ | |
77 | + [ 'city_id' ], | |
78 | + 'exist', | |
79 | + 'skipOnError' => true, | |
80 | + 'targetClass' => City::className(), | |
81 | + 'targetAttribute' => [ 'city_id' => 'id' ], | |
82 | + ], | |
83 | + ]; | |
84 | + } | |
85 | + | |
86 | + /** | |
87 | + * @inheritdoc | |
88 | + */ | |
89 | + public function attributeLabels() | |
90 | + { | |
91 | + return [ | |
92 | + 'id' => 'ID', | |
93 | + 'mode' => \Yii::t('stock', 'Mode'), | |
94 | + 'city_id' => 'City ID', | |
95 | + 'sort' => \Yii::t('stock', 'Sort'), | |
96 | + 'status' => \Yii::t('stock', 'Status'), | |
97 | + ]; | |
98 | + } | |
99 | + | |
100 | + /** | |
101 | + * @return \yii\db\ActiveQuery | |
102 | + */ | |
103 | + public function getCity() | |
104 | + { | |
105 | + return $this->hasOne(City::className(), [ 'id' => 'city_id' ]); | |
106 | + } | |
107 | + | |
108 | + public function getCities() | |
109 | + { | |
110 | + $cities = City::find() | |
111 | + ->with([ 'lang' ]) | |
112 | + ->all(); | |
113 | + foreach ($cities as $city) { | |
114 | + $this->cities[ $city->id ] = $city->lang->title; | |
115 | + } | |
116 | + | |
117 | + } | |
118 | + | |
119 | + /** | |
120 | + * @return \yii\db\ActiveQuery | |
121 | + */ | |
122 | + public function getShopLangs() | |
123 | + { | |
124 | + return $this->hasMany(ShopLang::className(), [ 'shop_id' => 'id' ]); | |
125 | + } | |
126 | + | |
127 | + /** | |
128 | + * @return \yii\db\ActiveQuery | |
129 | + */ | |
130 | + public function getLanguages() | |
131 | + { | |
132 | + return $this->hasMany(Language::className(), [ 'id' => 'language_id' ]) | |
133 | + ->viaTable('shop_lang', [ 'shop_id' => 'id' ]); | |
134 | + } | |
135 | + | |
136 | + public function setModeStr($value) | |
137 | + { | |
138 | + $this->mode = Json::encode($value); | |
139 | + } | |
140 | + | |
141 | + public function getModeStr() | |
142 | + { | |
143 | + return Json::decode($this->mode); | |
144 | + } | |
145 | + | |
146 | + public function setCoordsArr($value) | |
147 | + { | |
148 | + $this->coords = Json::encode($value); | |
149 | + } | |
150 | + | |
151 | + public function getCoordsArr() | |
152 | + { | |
153 | + return Json::decode($this->coords); | |
154 | + } | |
155 | + | |
115 | 156 | } |
116 | - | |
117 | - | |
118 | -} | ... | ... |
models/ShopLang.php
1 | 1 | <?php |
2 | - | |
3 | -namespace artbox\stock\models; | |
4 | - | |
5 | -use Yii; | |
6 | -use artbox\core\models\Alias; | |
7 | -use artbox\core\models\Language; | |
8 | -use artbox\core\behaviors\SlugBehavior; | |
9 | -/** | |
10 | - * This is the model class for table "shop_lang". | |
11 | - * | |
12 | - * @property integer $shop_id | |
13 | - * @property integer $language_id | |
14 | - * @property string $title | |
15 | - * @property integer $alias_id | |
16 | - * @property string $description | |
17 | - * | |
18 | - * @property Alias $alias | |
19 | - * @property Language $language | |
20 | - * @property Shop $shop | |
21 | - */ | |
22 | -class ShopLang extends \yii\db\ActiveRecord | |
23 | -{ | |
2 | + | |
3 | + namespace artbox\stock\models; | |
4 | + | |
5 | + use artbox\core\behaviors\SlugBehavior; | |
6 | + use artbox\core\models\Alias; | |
7 | + use artbox\core\models\Language; | |
8 | + use yii\db\ActiveRecord; | |
9 | + | |
24 | 10 | /** |
25 | - * @inheritdoc | |
11 | + * This is the model class for table "shop_lang". | |
12 | + * | |
13 | + * @property integer $shop_id | |
14 | + * @property integer $language_id | |
15 | + * @property string $title | |
16 | + * @property integer $alias_id | |
17 | + * @property string $description | |
18 | + * @property Alias $alias | |
19 | + * @property Language $language | |
20 | + * @property Shop $shop | |
26 | 21 | */ |
27 | - public static function tableName() | |
22 | + class ShopLang extends ActiveRecord | |
28 | 23 | { |
29 | - return 'shop_lang'; | |
30 | - } | |
31 | - | |
32 | - /** | |
33 | - * @inheritdoc | |
34 | - */ | |
35 | - public function behaviors() | |
36 | - { | |
37 | - return [ | |
38 | - 'slug' => [ | |
39 | - 'class' => SlugBehavior::className(), | |
40 | - 'action' => 'shop/view', | |
41 | - 'params' => [ | |
42 | - 'id' => 'shop_id', | |
24 | + /** | |
25 | + * @inheritdoc | |
26 | + */ | |
27 | + public static function tableName() | |
28 | + { | |
29 | + return 'shop_lang'; | |
30 | + } | |
31 | + | |
32 | + /** | |
33 | + * @inheritdoc | |
34 | + */ | |
35 | + public function behaviors() | |
36 | + { | |
37 | + return [ | |
38 | + 'slug' => [ | |
39 | + 'class' => SlugBehavior::className(), | |
40 | + 'action' => 'shop/view', | |
41 | + 'params' => [ | |
42 | + 'id' => 'shop_id', | |
43 | + ], | |
44 | + 'fields' => [ | |
45 | + 'title' => \Yii::t('stock', 'Title'), | |
46 | + 'description' => \Yii::t('stock', 'Description'), | |
47 | + 'address' => \Yii::t('stock', 'Address'), | |
48 | + ], | |
43 | 49 | ], |
44 | - 'fields' => [ | |
45 | - 'title' => \Yii::t('stock', 'Title'), | |
46 | - 'description' => \Yii::t('stock', 'Description'), | |
47 | - 'address' => \Yii::t('stock', 'Address'), | |
50 | + ]; | |
51 | + } | |
52 | + public function rules() | |
53 | + { | |
54 | + return [ | |
55 | + [ | |
56 | + [ | |
57 | + 'shop_id', | |
58 | + 'language_id', | |
59 | + 'title', | |
60 | + ], | |
61 | + 'required', | |
48 | 62 | ], |
49 | - ], | |
50 | - ]; | |
51 | - } | |
52 | - public function rules() | |
53 | - { | |
54 | - return [ | |
55 | - [['shop_id', 'language_id', 'title'], 'required'], | |
56 | - [['shop_id', 'language_id', 'alias_id'], 'integer'], | |
57 | - [['description'], 'string'], | |
58 | - [['title'], 'string', 'max' => 255], | |
59 | - [['address'], 'string', 'max' => 255], | |
60 | - [['alias_id'], 'unique'], | |
61 | - [['alias_id'], 'exist', 'skipOnError' => true, 'targetClass' => Alias::className(), 'targetAttribute' => ['alias_id' => 'id']], | |
62 | - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'id']], | |
63 | - [['shop_id'], 'exist', 'skipOnError' => true, 'targetClass' => Shop::className(), 'targetAttribute' => ['shop_id' => 'id']], | |
64 | - ]; | |
65 | - } | |
66 | - | |
67 | - /** | |
68 | - * @inheritdoc | |
69 | - */ | |
70 | - public function attributeLabels() | |
71 | - { | |
72 | - return [ | |
73 | - 'shop_id' => 'Shop ID', | |
74 | - 'language_id' => 'Language ID', | |
75 | - 'title' => \Yii::t('stock', 'Title'), | |
76 | - 'alias_id' => 'Alias ID', | |
77 | - 'description' => \Yii::t('stock', 'Description'), | |
78 | - 'address' => \Yii::t('stock', 'Address'), | |
79 | - ]; | |
80 | - } | |
81 | - | |
82 | - /** | |
83 | - * @return \yii\db\ActiveQuery | |
84 | - */ | |
85 | - public function getAlias() | |
86 | - { | |
87 | - return $this->hasOne(Alias::className(), ['id' => 'alias_id']); | |
88 | - } | |
89 | - | |
90 | - /** | |
91 | - * @return \yii\db\ActiveQuery | |
92 | - */ | |
93 | - public function getLanguage() | |
94 | - { | |
95 | - return $this->hasOne(Language::className(), ['id' => 'language_id']); | |
96 | - } | |
97 | - | |
98 | - /** | |
99 | - * @return \yii\db\ActiveQuery | |
100 | - */ | |
101 | - public function getShop() | |
102 | - { | |
103 | - return $this->hasOne(Shop::className(), ['id' => 'shop_id']); | |
63 | + [ | |
64 | + [ | |
65 | + 'shop_id', | |
66 | + 'language_id', | |
67 | + 'alias_id', | |
68 | + ], | |
69 | + 'integer', | |
70 | + ], | |
71 | + [ | |
72 | + [ 'description' ], | |
73 | + 'string', | |
74 | + ], | |
75 | + [ | |
76 | + [ 'title' ], | |
77 | + 'string', | |
78 | + 'max' => 255, | |
79 | + ], | |
80 | + [ | |
81 | + [ 'address' ], | |
82 | + 'string', | |
83 | + 'max' => 255, | |
84 | + ], | |
85 | + [ | |
86 | + [ 'alias_id' ], | |
87 | + 'unique', | |
88 | + ], | |
89 | + [ | |
90 | + [ 'alias_id' ], | |
91 | + 'exist', | |
92 | + 'skipOnError' => true, | |
93 | + 'targetClass' => Alias::className(), | |
94 | + 'targetAttribute' => [ 'alias_id' => 'id' ], | |
95 | + ], | |
96 | + [ | |
97 | + [ 'language_id' ], | |
98 | + 'exist', | |
99 | + 'skipOnError' => true, | |
100 | + 'targetClass' => Language::className(), | |
101 | + 'targetAttribute' => [ 'language_id' => 'id' ], | |
102 | + ], | |
103 | + [ | |
104 | + [ 'shop_id' ], | |
105 | + 'exist', | |
106 | + 'skipOnError' => true, | |
107 | + 'targetClass' => Shop::className(), | |
108 | + 'targetAttribute' => [ 'shop_id' => 'id' ], | |
109 | + ], | |
110 | + ]; | |
111 | + } | |
112 | + | |
113 | + /** | |
114 | + * @inheritdoc | |
115 | + */ | |
116 | + public function attributeLabels() | |
117 | + { | |
118 | + return [ | |
119 | + 'shop_id' => 'Shop ID', | |
120 | + 'language_id' => 'Language ID', | |
121 | + 'title' => \Yii::t('stock', 'Title'), | |
122 | + 'alias_id' => 'Alias ID', | |
123 | + 'description' => \Yii::t('stock', 'Description'), | |
124 | + 'address' => \Yii::t('stock', 'Address'), | |
125 | + ]; | |
126 | + } | |
127 | + | |
128 | + /** | |
129 | + * @return \yii\db\ActiveQuery | |
130 | + */ | |
131 | + public function getAlias() | |
132 | + { | |
133 | + return $this->hasOne(Alias::className(), [ 'id' => 'alias_id' ]); | |
134 | + } | |
135 | + | |
136 | + /** | |
137 | + * @return \yii\db\ActiveQuery | |
138 | + */ | |
139 | + public function getLanguage() | |
140 | + { | |
141 | + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); | |
142 | + } | |
143 | + | |
144 | + /** | |
145 | + * @return \yii\db\ActiveQuery | |
146 | + */ | |
147 | + public function getShop() | |
148 | + { | |
149 | + return $this->hasOne(Shop::className(), [ 'id' => 'shop_id' ]); | |
150 | + } | |
104 | 151 | } |
105 | -} | ... | ... |
views/city/_form.php
1 | 1 | <?php |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | -use yii\widgets\ActiveForm; | |
5 | -use artbox\core\widgets\LanguageForm; | |
6 | - | |
7 | -/* @var $this yii\web\View */ | |
8 | -/* @var $model artbox\stock\models\City */ | |
9 | -/* @var $form yii\widgets\ActiveForm */ | |
2 | + | |
3 | + use yii\helpers\Html; | |
4 | + use yii\widgets\ActiveForm; | |
5 | + use artbox\core\widgets\LanguageForm; | |
6 | + | |
7 | + /* @var $this yii\web\View */ | |
8 | + /* @var $model artbox\stock\models\City */ | |
9 | + /* @var $form yii\widgets\ActiveForm */ | |
10 | + /* @var $modelLangs artbox\stock\models\CityLang */ | |
10 | 11 | ?> |
11 | 12 | |
12 | 13 | <div class="city-form"> |
13 | - | |
14 | + | |
14 | 15 | <?php $form = ActiveForm::begin(); ?> |
15 | 16 | <?= LanguageForm::widget( |
16 | 17 | [ |
... | ... | @@ -19,15 +20,20 @@ use artbox\core\widgets\LanguageForm; |
19 | 20 | 'form' => $form, |
20 | 21 | ] |
21 | 22 | ) ?> |
22 | - | |
23 | - <?= $form->field($model, 'sort')->textInput() ?> | |
24 | - | |
25 | - <?= $form->field($model, 'status')->checkbox() ?> | |
26 | - | |
27 | - <div class="form-group"> | |
28 | - <?= Html::submitButton($model->isNewRecord ? \Yii::t('stock', 'Create'): \Yii::t('stock', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | |
29 | - </div> | |
30 | - | |
23 | + | |
24 | + <?= $form->field($model, 'sort') | |
25 | + ->textInput() ?> | |
26 | + | |
27 | + <?= $form->field($model, 'status') | |
28 | + ->checkbox() ?> | |
29 | + | |
30 | + <div class="form-group"> | |
31 | + <?= Html::submitButton( | |
32 | + $model->isNewRecord ? \Yii::t('stock', 'Create') : \Yii::t('stock', 'Update'), | |
33 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | |
34 | + ) ?> | |
35 | + </div> | |
36 | + | |
31 | 37 | <?php ActiveForm::end(); ?> |
32 | 38 | |
33 | 39 | </div> | ... | ... |
views/city/_form_language.php
1 | 1 | <?php |
2 | - use artbox\catalog\models\BrandLang; | |
2 | + use artbox\stock\models\CityLang; | |
3 | 3 | use artbox\core\helpers\SlugifyDecorator; |
4 | 4 | use artbox\core\models\Language; |
5 | 5 | use dosamigos\tinymce\TinyMce; |
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | use yii\widgets\ActiveForm; |
8 | 8 | |
9 | 9 | /** |
10 | - * @var BrandLang $model_lang | |
10 | + * @var CityLang $model_lang | |
11 | 11 | * @var Language $language |
12 | 12 | * @var ActiveForm $form |
13 | 13 | * @var View $this | ... | ... |
views/city/create.php
1 | 1 | <?php |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | -use yiister\gentelella\widgets\Panel; | |
5 | - | |
6 | - | |
7 | -/* @var $this yii\web\View */ | |
8 | -/* @var $model artbox\stock\models\City */ | |
9 | - | |
10 | -$this->title = \Yii::t('stock', 'Create City'); | |
11 | -$this->params['breadcrumbs'][] = ['label' => \Yii::t('stock', 'Cities'), 'url' => ['index']]; | |
12 | -$this->params['breadcrumbs'][] = \Yii::t('stock', $this->title); | |
2 | + | |
3 | + use yii\helpers\Html; | |
4 | + use yiister\gentelella\widgets\Panel; | |
5 | + | |
6 | + /* @var $this yii\web\View */ | |
7 | + /* @var $model artbox\stock\models\City */ | |
8 | + /* @var $modelLangs artbox\stock\models\CityLang */ | |
9 | + | |
10 | + $this->title = \Yii::t('stock', 'Create City'); | |
11 | + $this->params[ 'breadcrumbs' ][] = [ | |
12 | + 'label' => \Yii::t('stock', 'Cities'), | |
13 | + 'url' => [ 'index' ], | |
14 | + ]; | |
15 | + $this->params[ 'breadcrumbs' ][] = \Yii::t('stock', $this->title); | |
13 | 16 | ?> |
14 | 17 | <div class="city-create"> |
15 | 18 | <?php |
16 | - $xPanel = Panel::begin( | |
19 | + $xPanel = Panel::begin( | |
20 | + [ | |
21 | + 'header' => \Yii::t('stock', Html::encode($this->title)), | |
22 | + ] | |
23 | + ); | |
24 | + ?> | |
25 | + <h1><?= \Yii::t('stock', Html::encode($this->title)) ?></h1> | |
26 | + | |
27 | + <?= $this->render( | |
28 | + '_form', | |
17 | 29 | [ |
18 | - 'header' => \Yii::t('stock', Html::encode($this->title)), | |
30 | + 'model' => $model, | |
31 | + 'modelLangs' => $modelLangs, | |
19 | 32 | ] |
20 | - ); | |
21 | - ?> | |
22 | - <h1><?= \Yii::t('stock', Html::encode($this->title)) ?></h1> | |
23 | - | |
24 | - <?= $this->render('_form', [ | |
25 | - 'model' => $model, | |
26 | - 'modelLangs' => $modelLangs, | |
27 | - ]) ?> | |
28 | - | |
29 | - | |
33 | + ) ?> | |
34 | + | |
35 | + | |
30 | 36 | <?php |
31 | - $xPanel::end(); | |
37 | + $xPanel::end(); | |
32 | 38 | ?> |
33 | 39 | </div> | ... | ... |
views/city/update.php
1 | 1 | <?php |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | - | |
5 | -/* @var $this yii\web\View */ | |
6 | -/* @var $model artbox\stock\models\City */ | |
7 | - | |
8 | -$this->title = Yii::t( | |
9 | - 'catalog', | |
10 | - 'Update {modelClass}: ', | |
11 | - [ | |
12 | - 'modelClass' => 'City', | |
13 | - ] | |
14 | - ) . $model->lang->title; | |
15 | -$this->params[ 'breadcrumbs' ][] = [ | |
16 | - 'label' => Yii::t('stock', 'Cities'), | |
17 | - 'url' => [ 'index' ], | |
18 | -]; | |
19 | -$this->params[ 'breadcrumbs' ][] = [ | |
20 | - 'label' => $model->lang->title, | |
21 | - 'url' => [ | |
22 | - 'view', | |
23 | - 'id' => $model->id, | |
24 | - ], | |
25 | -]; | |
26 | -$this->params[ 'breadcrumbs' ][] = Yii::t('stock', 'Update'); | |
2 | + | |
3 | + use yii\helpers\Html; | |
4 | + | |
5 | + /* @var $this yii\web\View */ | |
6 | + /* @var $model artbox\stock\models\City */ | |
7 | + /* @var $modelLangs artbox\stock\models\CityLang */ | |
8 | + | |
9 | + $this->title = Yii::t( | |
10 | + 'catalog', | |
11 | + 'Update {modelClass}: ', | |
12 | + [ | |
13 | + 'modelClass' => 'City', | |
14 | + ] | |
15 | + ) . $model->lang->title; | |
16 | + $this->params[ 'breadcrumbs' ][] = [ | |
17 | + 'label' => Yii::t('stock', 'Cities'), | |
18 | + 'url' => [ 'index' ], | |
19 | + ]; | |
20 | + $this->params[ 'breadcrumbs' ][] = [ | |
21 | + 'label' => $model->lang->title, | |
22 | + 'url' => [ | |
23 | + 'view', | |
24 | + 'id' => $model->id, | |
25 | + ], | |
26 | + ]; | |
27 | + $this->params[ 'breadcrumbs' ][] = Yii::t('stock', 'Update'); | |
27 | 28 | ?> |
28 | 29 | <div class="city-update"> |
29 | - | |
30 | - <h1><?= Html::encode($this->title) ?></h1> | |
31 | - | |
32 | - <?= $this->render('_form', [ | |
33 | - 'model' => $model, | |
34 | - 'modelLangs' => $modelLangs, | |
35 | - ]) ?> | |
30 | + | |
31 | + <h1><?= Html::encode($this->title) ?></h1> | |
32 | + | |
33 | + <?= $this->render( | |
34 | + '_form', | |
35 | + [ | |
36 | + 'model' => $model, | |
37 | + 'modelLangs' => $modelLangs, | |
38 | + ] | |
39 | + ) ?> | |
36 | 40 | |
37 | 41 | </div> | ... | ... |
views/city/view.php
1 | 1 | <?php |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | -use yii\widgets\DetailView; | |
5 | -use yiister\gentelella\widgets\Panel; | |
6 | -/* @var $this yii\web\View */ | |
7 | -/* @var $model artbox\stock\models\City */ | |
8 | - | |
9 | - | |
10 | -$this->title = $model->lang->title; | |
11 | -$this->params[ 'breadcrumbs' ][] = [ | |
12 | - 'label' => Yii::t('stock', 'Cities'), | |
13 | - 'url' => [ 'index' ], | |
14 | -]; | |
15 | -$this->params[ 'breadcrumbs' ][] = $this->title; | |
2 | + | |
3 | + use yii\helpers\Html; | |
4 | + use yii\widgets\DetailView; | |
5 | + use yiister\gentelella\widgets\Panel; | |
6 | + | |
7 | + /* @var $this yii\web\View */ | |
8 | + /* @var $model artbox\stock\models\City */ | |
9 | + | |
10 | + $this->title = $model->lang->title; | |
11 | + $this->params[ 'breadcrumbs' ][] = [ | |
12 | + 'label' => Yii::t('stock', 'Cities'), | |
13 | + 'url' => [ 'index' ], | |
14 | + ]; | |
15 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
16 | 16 | ?> |
17 | 17 | <div class="city-view"> |
18 | 18 | <?php |
19 | - $xPanel = Panel::begin( | |
20 | - [ | |
21 | - 'header' => Html::encode($this->title), | |
22 | - ] | |
23 | - ); | |
24 | - ?> | |
25 | - <h1><?= Html::encode($this->title) ?></h1> | |
26 | - | |
27 | - <p> | |
28 | - <?= Html::a(\Yii::t('stock', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> | |
29 | - <?= Html::a(\Yii::t('stock', 'Delete'), ['delete', 'id' => $model->id], [ | |
30 | - 'class' => 'btn btn-danger', | |
31 | - 'data' => [ | |
32 | - 'confirm' => 'Are you sure you want to delete this item?', | |
33 | - 'method' => 'post', | |
34 | - ], | |
35 | - ]) ?> | |
36 | - </p> | |
37 | - | |
38 | - <?= DetailView::widget([ | |
39 | - 'model' => $model, | |
40 | - 'attributes' => [ | |
41 | - 'id', | |
42 | - 'lang.title', | |
19 | + $xPanel = Panel::begin( | |
43 | 20 | [ |
44 | - 'attribute' => 'lang.alias.value', | |
45 | - 'label' => \Yii::t('catalog', 'Alias'), | |
21 | + 'header' => Html::encode($this->title), | |
22 | + ] | |
23 | + ); | |
24 | + ?> | |
25 | + <h1><?= Html::encode($this->title) ?></h1> | |
26 | + | |
27 | + <p> | |
28 | + <?= Html::a( | |
29 | + \Yii::t('stock', 'Update'), | |
30 | + [ | |
31 | + 'update', | |
32 | + 'id' => $model->id, | |
33 | + ], | |
34 | + [ 'class' => 'btn btn-primary' ] | |
35 | + ) ?> | |
36 | + <?= Html::a( | |
37 | + \Yii::t('stock', 'Delete'), | |
38 | + [ | |
39 | + 'delete', | |
40 | + 'id' => $model->id, | |
41 | + ], | |
42 | + [ | |
43 | + 'class' => 'btn btn-danger', | |
44 | + 'data' => [ | |
45 | + 'confirm' => 'Are you sure you want to delete this item?', | |
46 | + 'method' => 'post', | |
47 | + ], | |
48 | + ] | |
49 | + ) ?> | |
50 | + </p> | |
51 | + | |
52 | + <?= DetailView::widget( | |
53 | + [ | |
54 | + 'model' => $model, | |
55 | + 'attributes' => [ | |
56 | + 'id', | |
57 | + 'lang.title', | |
58 | + [ | |
59 | + 'attribute' => 'lang.alias.value', | |
60 | + 'label' => \Yii::t('catalog', 'Alias'), | |
61 | + ], | |
62 | + 'lang.description:html', | |
63 | + 'sort', | |
64 | + 'status:boolean', | |
46 | 65 | ], |
47 | - 'lang.description:html', | |
48 | - 'sort', | |
49 | - 'status:boolean', | |
50 | - ], | |
51 | - ]) ?> | |
66 | + ] | |
67 | + ) ?> | |
52 | 68 | |
53 | 69 | </div> | ... | ... |
views/shop/_form.php
... | ... | @@ -8,14 +8,15 @@ |
8 | 8 | /* @var $this yii\web\View */ |
9 | 9 | /* @var $model artbox\stock\models\Shop */ |
10 | 10 | /* @var $form yii\widgets\ActiveForm */ |
11 | + /* @var $modelLangs artbox\stock\models\ShopLang */ | |
11 | 12 | $days = [ |
12 | - \Yii::t('stock', 'ะะฝ'), | |
13 | - "ะั", | |
14 | - "ะกั", | |
15 | - "ะงั", | |
16 | - "ะั", | |
17 | - "ะกะฑ", | |
18 | - "ะั", | |
13 | + \Yii::t('stock', 'Mon'), | |
14 | + \Yii::t('stock', 'Tue'), | |
15 | + \Yii::t('stock', 'Wed'), | |
16 | + \Yii::t('stock', 'Thu'), | |
17 | + \Yii::t('stock', 'Fri'), | |
18 | + \Yii::t('stock', 'Sat'), | |
19 | + \Yii::t('stock', 'Sun'), | |
19 | 20 | ]; |
20 | 21 | |
21 | 22 | \artbox\stock\assets\StockAsset::register($this); |
... | ... | @@ -135,9 +136,4 @@ |
135 | 136 | |
136 | 137 | <?php ActiveForm::end(); ?> |
137 | 138 | </div> |
138 | -<!--<script>--> | |
139 | -<!-- window.onload = function () {--> | |
140 | -<!-- console.log('ololo');--> | |
141 | -<!-- --> | |
142 | -<!-- }--> | |
143 | -<!--</script>--> | |
139 | + | ... | ... |
views/shop/_form_language.php
1 | 1 | <?php |
2 | - use artbox\catalog\models\BrandLang; | |
3 | 2 | use artbox\core\helpers\SlugifyDecorator; |
4 | 3 | use artbox\core\models\Language; |
5 | 4 | use dosamigos\tinymce\TinyMce; |
6 | 5 | use yii\web\View; |
7 | 6 | use yii\widgets\ActiveForm; |
8 | -use yii\helpers\Html; | |
7 | + use yii\helpers\Html; | |
8 | + use artbox\stock\models\ShopLang; | |
9 | + | |
9 | 10 | /** |
10 | - * @var BrandLang $model_lang | |
11 | + * @var ShopLang $model_lang | |
11 | 12 | * @var Language $language |
12 | 13 | * @var ActiveForm $form |
13 | 14 | * @var View $this |
14 | 15 | */ |
15 | - //print_r($model_lang->shop->coordsArr); die(); | |
16 | 16 | ?> |
17 | 17 | <?php |
18 | 18 | $attributeField = $form->field($model_lang, '[' . $language->id . ']title') |
... | ... | @@ -21,23 +21,31 @@ use yii\helpers\Html; |
21 | 21 | ?> |
22 | 22 | |
23 | 23 | <?php |
24 | -$attributeField = $form->field($model_lang, '[' . $language->id . ']address') | |
25 | - ->textInput([ 'maxlength' => true ]); | |
26 | -echo $attributeField; | |
24 | + $attributeField = $form->field($model_lang, '[' . $language->id . ']address') | |
25 | + ->textInput([ 'maxlength' => true ]); | |
26 | + echo $attributeField; | |
27 | 27 | ?> |
28 | -<?= Html::label('ะะพะพัะดะธะฝะฐัั');?> | |
29 | -<?= Html::textInput("Shop[coordsArr][lat]", (isset($model_lang->shop->coordsArr['lat'])) ? $model_lang->shop->coordsArr['lat'] : '', [ | |
30 | - 'size' => 20, | |
31 | - 'type'=> 'text', | |
32 | - 'id' => 'lat', | |
33 | - | |
34 | -])?> | |
35 | -<?= Html::textInput("Shop[coordsArr][lng]", (isset($model_lang->shop->coordsArr['lng'])) ? $model_lang->shop->coordsArr['lng'] : '', [ | |
36 | - 'size' => 20, | |
37 | - 'type'=> 'text', | |
38 | - 'id' => 'lng' | |
39 | -])?> | |
40 | - <div id="map_canvas" style="height: 300px;"></div> | |
28 | +<?= Html::label('ะะพะพัะดะธะฝะฐัั'); ?> | |
29 | +<?= Html::textInput( | |
30 | + "Shop[coordsArr][lat]", | |
31 | + ( isset($model_lang->shop->coordsArr[ 'lat' ]) ) ? $model_lang->shop->coordsArr[ 'lat' ] : '', | |
32 | + [ | |
33 | + 'size' => 20, | |
34 | + 'type' => 'text', | |
35 | + 'id' => 'lat', | |
36 | + | |
37 | + ] | |
38 | +) ?> | |
39 | +<?= Html::textInput( | |
40 | + "Shop[coordsArr][lng]", | |
41 | + ( isset($model_lang->shop->coordsArr[ 'lng' ]) ) ? $model_lang->shop->coordsArr[ 'lng' ] : '', | |
42 | + [ | |
43 | + 'size' => 20, | |
44 | + 'type' => 'text', | |
45 | + 'id' => 'lng', | |
46 | + ] | |
47 | +) ?> | |
48 | + <div id="map_canvas" style="height: 300px;"></div> | |
41 | 49 | |
42 | 50 | <?= SlugifyDecorator::decorate( |
43 | 51 | $form->field($model_lang, '[' . $language->id . ']aliasValue'), | ... | ... |
views/shop/create.php
1 | 1 | <?php |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | -use yiister\gentelella\widgets\Panel; | |
5 | - | |
6 | -/* @var $this yii\web\View */ | |
7 | -/* @var $model artbox\stock\models\Shop */ | |
8 | - | |
9 | -$this->title = \Yii::t('stock', 'Create Shop'); | |
10 | -$this->params['breadcrumbs'][] = ['label' => \Yii::t('stock', 'Shops'), 'url' => ['index']]; | |
11 | -$this->params['breadcrumbs'][] = \Yii::t('stock', $this->title); | |
2 | + | |
3 | + use yii\helpers\Html; | |
4 | + use yiister\gentelella\widgets\Panel; | |
5 | + | |
6 | + /* @var $this yii\web\View */ | |
7 | + /* @var $model artbox\stock\models\Shop */ | |
8 | + /* @var $modelLangs artbox\stock\models\ShopLang */ | |
9 | + | |
10 | + $this->title = \Yii::t('stock', 'Create Shop'); | |
11 | + $this->params[ 'breadcrumbs' ][] = [ | |
12 | + 'label' => \Yii::t('stock', 'Shops'), | |
13 | + 'url' => [ 'index' ], | |
14 | + ]; | |
15 | + $this->params[ 'breadcrumbs' ][] = \Yii::t('stock', $this->title); | |
12 | 16 | ?> |
13 | 17 | <div class="shop-create"> |
14 | 18 | <?php |
15 | - $xPanel = Panel::begin( | |
19 | + $xPanel = Panel::begin( | |
20 | + [ | |
21 | + 'header' => \Yii::t('stock', Html::encode($this->title)), | |
22 | + ] | |
23 | + ); | |
24 | + ?> | |
25 | + <h1><?= Html::encode($this->title) ?></h1> | |
26 | + | |
27 | + <?= $this->render( | |
28 | + '_form', | |
16 | 29 | [ |
17 | - 'header' => \Yii::t('stock', Html::encode($this->title)), | |
30 | + 'model' => $model, | |
31 | + 'modelLangs' => $modelLangs, | |
18 | 32 | ] |
19 | - ); | |
20 | - ?> | |
21 | - <h1><?= Html::encode($this->title) ?></h1> | |
22 | - | |
23 | - <?= $this->render('_form', [ | |
24 | - 'model' => $model, | |
25 | - 'modelLangs' => $modelLangs, | |
26 | - ]) ?> | |
33 | + ) ?> | |
27 | 34 | <?php |
28 | - $xPanel::end(); | |
35 | + $xPanel::end(); | |
29 | 36 | ?> |
30 | 37 | </div> | ... | ... |
views/shop/index.php
1 | 1 | <?php |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | -use yii\grid\GridView; | |
5 | -use yiister\gentelella\widgets\Panel; | |
6 | - | |
7 | -/* @var $this yii\web\View */ | |
8 | -/* @var $dataProvider yii\data\ActiveDataProvider */ | |
9 | - | |
10 | -$this->title = 'Shops'; | |
11 | -$this->params['breadcrumbs'][] = \Yii::t('stock', $this->title); | |
2 | + | |
3 | + use yii\helpers\Html; | |
4 | + use yii\grid\GridView; | |
5 | + use yiister\gentelella\widgets\Panel; | |
6 | + | |
7 | + /* @var $this yii\web\View */ | |
8 | + /* @var $dataProvider yii\data\ActiveDataProvider */ | |
9 | + | |
10 | + $this->title = 'Shops'; | |
11 | + $this->params[ 'breadcrumbs' ][] = \Yii::t('stock', $this->title); | |
12 | 12 | ?> |
13 | 13 | <div class="shop-index"> |
14 | 14 | <?php |
15 | - $xPanel = Panel::begin( | |
16 | - [ | |
17 | - 'header' => \Yii::t('stock', Html::encode($this->title)), | |
18 | - ] | |
19 | - ); | |
20 | - ?> | |
21 | - <h1><?= \Yii::t('stock', Html::encode($this->title)) ?></h1> | |
22 | - | |
23 | - <p> | |
24 | - <?= Html::a(\Yii::t('stock', 'Create Shop'), ['create'], ['class' => 'btn btn-success']) ?> | |
25 | - </p> | |
26 | - <?= GridView::widget([ | |
27 | - 'dataProvider' => $dataProvider, | |
28 | - 'columns' => [ | |
29 | - ['class' => 'yii\grid\SerialColumn'], | |
30 | - | |
31 | - 'id', | |
15 | + $xPanel = Panel::begin( | |
32 | 16 | [ |
33 | - 'attribute' => \Yii::t('stock', 'Address'), | |
34 | - 'value' => 'lang.address', | |
17 | + 'header' => \Yii::t('stock', Html::encode($this->title)), | |
18 | + ] | |
19 | + ); | |
20 | + ?> | |
21 | + <h1><?= \Yii::t('stock', Html::encode($this->title)) ?></h1> | |
22 | + | |
23 | + <p> | |
24 | + <?= Html::a(\Yii::t('stock', 'Create Shop'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> | |
25 | + </p> | |
26 | + <?= GridView::widget( | |
27 | + [ | |
28 | + 'dataProvider' => $dataProvider, | |
29 | + 'columns' => [ | |
30 | + [ 'class' => 'yii\grid\SerialColumn' ], | |
31 | + | |
32 | + 'id', | |
33 | + [ | |
34 | + 'attribute' => \Yii::t('stock', 'Address'), | |
35 | + 'value' => 'lang.address', | |
36 | + ], | |
37 | + 'sort', | |
38 | + 'status:boolean', | |
39 | + | |
40 | + [ 'class' => 'yii\grid\ActionColumn' ], | |
35 | 41 | ], |
36 | - 'sort', | |
37 | - 'status:boolean', | |
38 | - | |
39 | - ['class' => 'yii\grid\ActionColumn'], | |
40 | - ], | |
41 | - ]); ?> | |
42 | + ] | |
43 | + ); ?> | |
42 | 44 | <?php |
43 | - $xPanel::end(); | |
45 | + $xPanel::end(); | |
44 | 46 | ?> |
45 | 47 | </div> | ... | ... |
views/shop/update.php
1 | 1 | <?php |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | -use yiister\gentelella\widgets\Panel; | |
5 | -/* @var $this yii\web\View */ | |
6 | -/* @var $model artbox\stock\models\Shop */ | |
7 | - | |
8 | -$this->title = Yii::t( | |
9 | - 'catalog', | |
10 | - 'Update {modelClass}: ', | |
11 | - [ | |
12 | - 'modelClass' => 'Shop', | |
13 | - ] | |
14 | - ) . $model->lang->title; | |
15 | -$this->params[ 'breadcrumbs' ][] = [ | |
16 | - 'label' => Yii::t('stock', 'Shop'), | |
17 | - 'url' => [ 'index' ], | |
18 | -]; | |
19 | -$this->params[ 'breadcrumbs' ][] = [ | |
20 | - 'label' => $model->lang->title, | |
21 | - 'url' => [ | |
22 | - 'view', | |
23 | - 'id' => $model->id, | |
24 | - ], | |
25 | -]; | |
26 | -$this->params[ 'breadcrumbs' ][] = Yii::t('stock', 'Update');?> | |
2 | + | |
3 | + use yii\helpers\Html; | |
4 | + use yiister\gentelella\widgets\Panel; | |
5 | + | |
6 | + /* @var $this yii\web\View */ | |
7 | + /* @var $model artbox\stock\models\Shop */ | |
8 | + /* @var $modelLangs artbox\stock\models\ShopLang */ | |
9 | + | |
10 | + $this->title = Yii::t( | |
11 | + 'catalog', | |
12 | + 'Update {modelClass}: ', | |
13 | + [ | |
14 | + 'modelClass' => 'Shop', | |
15 | + ] | |
16 | + ) . $model->lang->title; | |
17 | + $this->params[ 'breadcrumbs' ][] = [ | |
18 | + 'label' => Yii::t('stock', 'Shop'), | |
19 | + 'url' => [ 'index' ], | |
20 | + ]; | |
21 | + $this->params[ 'breadcrumbs' ][] = [ | |
22 | + 'label' => $model->lang->title, | |
23 | + 'url' => [ | |
24 | + 'view', | |
25 | + 'id' => $model->id, | |
26 | + ], | |
27 | + ]; | |
28 | + $this->params[ 'breadcrumbs' ][] = Yii::t('stock', 'Update'); ?> | |
27 | 29 | <div class="shop-update"> |
28 | 30 | <?php |
29 | - $xPanel = Panel::begin( | |
31 | + $xPanel = Panel::begin( | |
32 | + [ | |
33 | + 'header' => \Yii::t('stock', Html::encode($this->title)), | |
34 | + ] | |
35 | + ); | |
36 | + ?> | |
37 | + <h1><?= Html::encode($this->title) ?></h1> | |
38 | + | |
39 | + <?= $this->render( | |
40 | + '_form', | |
30 | 41 | [ |
31 | - 'header' => \Yii::t('stock', Html::encode($this->title)), | |
42 | + 'model' => $model, | |
43 | + 'modelLangs' => $modelLangs, | |
32 | 44 | ] |
33 | - ); | |
34 | - ?> | |
35 | - <h1><?= Html::encode($this->title) ?></h1> | |
36 | - | |
37 | - <?= $this->render('_form', [ | |
38 | - 'model' => $model, | |
39 | - 'modelLangs' => $modelLangs, | |
40 | - ]) ?> | |
45 | + ) ?> | |
41 | 46 | <?php |
42 | - $xPanel::end(); | |
47 | + $xPanel::end(); | |
43 | 48 | ?> |
44 | 49 | </div> | ... | ... |
views/shop/view.php
1 | 1 | <?php |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | -use yii\widgets\DetailView; | |
5 | -use yiister\gentelella\widgets\Panel; | |
6 | -/* @var $this yii\web\View */ | |
7 | -/* @var $model artbox\stock\models\Shop */ | |
8 | - | |
9 | -$this->title = $model->lang->title; | |
10 | -$this->params[ 'breadcrumbs' ][] = [ | |
11 | - 'label' => Yii::t('stock', 'Shops'), | |
12 | - 'url' => [ 'index' ], | |
13 | -]; | |
14 | -$this->params[ 'breadcrumbs' ][] = $this->title; | |
2 | + | |
3 | + use yii\helpers\Html; | |
4 | + use yii\widgets\DetailView; | |
5 | + use yiister\gentelella\widgets\Panel; | |
6 | + | |
7 | + /* @var $this yii\web\View */ | |
8 | + /* @var $model artbox\stock\models\Shop */ | |
9 | + | |
10 | + $this->title = $model->lang->title; | |
11 | + $this->params[ 'breadcrumbs' ][] = [ | |
12 | + 'label' => Yii::t('stock', 'Shops'), | |
13 | + 'url' => [ 'index' ], | |
14 | + ]; | |
15 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
15 | 16 | ?> |
16 | 17 | <div class="shop-view"> |
17 | 18 | <?php |
18 | - $xPanel = Panel::begin( | |
19 | - [ | |
20 | - 'header' => \Yii::t('stock', Html::encode($this->title)), | |
21 | - ] | |
22 | - ); | |
23 | - ?> | |
24 | - <h1><?= Html::encode($this->title) ?></h1> | |
25 | - | |
26 | - <p> | |
27 | - <?= Html::a(\Yii::t('stock', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> | |
28 | - <?= Html::a(\Yii::t('stock', 'Delete'), ['delete', 'id' => $model->id], [ | |
29 | - 'class' => 'btn btn-danger', | |
30 | - 'data' => [ | |
31 | - 'confirm' => 'Are you sure you want to delete this item?', | |
32 | - 'method' => 'post', | |
33 | - ], | |
34 | - ]) ?> | |
35 | - </p> | |
36 | - | |
37 | - <?= DetailView::widget([ | |
38 | - 'model' => $model, | |
39 | - 'attributes' => [ | |
40 | - 'id', | |
41 | - 'lang.title', | |
19 | + $xPanel = Panel::begin( | |
42 | 20 | [ |
43 | - 'attribute' => 'lang.alias.value', | |
44 | - 'label' => \Yii::t('catalog', 'Alias'), | |
21 | + 'header' => \Yii::t('stock', Html::encode($this->title)), | |
22 | + ] | |
23 | + ); | |
24 | + ?> | |
25 | + <h1><?= Html::encode($this->title) ?></h1> | |
26 | + | |
27 | + <p> | |
28 | + <?= Html::a( | |
29 | + \Yii::t('stock', 'Update'), | |
30 | + [ | |
31 | + 'update', | |
32 | + 'id' => $model->id, | |
33 | + ], | |
34 | + [ 'class' => 'btn btn-primary' ] | |
35 | + ) ?> | |
36 | + <?= Html::a( | |
37 | + \Yii::t('stock', 'Delete'), | |
38 | + [ | |
39 | + 'delete', | |
40 | + 'id' => $model->id, | |
41 | + ], | |
42 | + [ | |
43 | + 'class' => 'btn btn-danger', | |
44 | + 'data' => [ | |
45 | + 'confirm' => 'Are you sure you want to delete this item?', | |
46 | + 'method' => 'post', | |
47 | + ], | |
48 | + ] | |
49 | + ) ?> | |
50 | + </p> | |
51 | + | |
52 | + <?= DetailView::widget( | |
53 | + [ | |
54 | + 'model' => $model, | |
55 | + 'attributes' => [ | |
56 | + 'id', | |
57 | + 'lang.title', | |
58 | + [ | |
59 | + 'attribute' => 'lang.alias.value', | |
60 | + 'label' => \Yii::t('catalog', 'Alias'), | |
61 | + ], | |
62 | + 'lang.description:html', | |
63 | + 'lang.address', | |
64 | + 'sort', | |
65 | + 'status:boolean', | |
45 | 66 | ], |
46 | - 'lang.description:html', | |
47 | - 'lang.address', | |
48 | - 'sort', | |
49 | - 'status:boolean', | |
50 | - ], | |
51 | - ]) ?> | |
67 | + ] | |
68 | + ) ?> | |
52 | 69 | <?php |
53 | - $xPanel::end(); | |
70 | + $xPanel::end(); | |
54 | 71 | ?> |
55 | 72 | </div> | ... | ... |