diff --git a/common/models/BlogSearch.php b/common/models/BlogSearch.php index 7437d09..15f26c1 100644 --- a/common/models/BlogSearch.php +++ b/common/models/BlogSearch.php @@ -47,17 +47,19 @@ ], [ [ - 'date_add_from', + 'date_add_to', ], - 'default', - 'value' => date('Y-m-d', 0), + 'compare', + 'compareAttribute' => 'date_add_from', + 'operator' => '>=', ], [ [ - 'date_add_to', + 'date_add_from', ], - 'default', - 'value' => date('Y-m-d'), + 'compare', + 'compareValue' => date('Y-m-d'), + 'operator' => '<=', ], ]; } @@ -101,17 +103,30 @@ // grid filtering conditions $query->andFilterWhere([ 'blog_id' => $this->blog_id, - 'date_add' => $this->date_add, 'user_add_id' => $this->user_add_id, 'view_count' => $this->view_count, ]); - $query->andFilterWhere([ - 'between', - 'date_add', - $this->date_add_from, - (new \DateTime($this->date_add_to))->modify('+1 day')->format('Y-m-d') - ]); + if(!empty($this->date_add_from) && !empty($this->date_add_to)) { + $query->andWhere([ + 'between', + 'date_add', + $this->date_add_from, + (new \DateTime($this->date_add_to))->modify('+1 day')->format('Y-m-d'), + ]); + } elseif(!empty($this->date_add_from)) { + $query->andWhere([ + '>=', + 'date_add', + $this->date_add_from, + ]); + } elseif(!empty($this->date_add_to)) { + $query->andWhere([ + '<=', + 'date_add', + (new \DateTime($this->date_add_to))->modify('+1 day')->format('Y-m-d'), + ]); + } $query->andFilterWhere([ 'like', diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index d40a8ca..63629f9 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -272,6 +272,10 @@ class SiteController extends Controller $user_info->load(Yii::$app->request->post(),'SignupForm'); + if(empty($user_info->city) && !empty(\Yii::$app->request->post()['SignupForm']['city_custom'])) { + $user_info->city = \Yii::$app->request->post()['SignupForm']['city_custom']; + } + $user_info->user_id = $user->id; $user_info->save(); diff --git a/frontend/models/SignupForm.php b/frontend/models/SignupForm.php index 9b71ea7..7638a01 100755 --- a/frontend/models/SignupForm.php +++ b/frontend/models/SignupForm.php @@ -23,7 +23,7 @@ class SignupForm extends Model public $is_freelancer; public $city; public $name; - + public $city_custom; const SCENARIO_USER = 'user'; @@ -40,7 +40,7 @@ class SignupForm extends Model ['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'], ['username', 'string', 'min' => 2, 'max' => 255], - ['city', 'string', 'min' => 2, 'max' => 255], + [['city', 'city_custom'], 'string', 'min' => 2, 'max' => 255], ['email', 'filter', 'filter' => 'trim'], ['email', 'required'], @@ -95,7 +95,6 @@ class SignupForm extends Model $user->generateAuthKey(); if ($user->save()) { -// $user->link('userInfo', new UserInfo(['city' => $this->city])); return $user; } } diff --git a/frontend/views/accounts/blog.php b/frontend/views/accounts/blog.php index 221c318..81a5763 100644 --- a/frontend/views/accounts/blog.php +++ b/frontend/views/accounts/blog.php @@ -59,7 +59,9 @@ 'changeMonth' => true, ], ]) - ." + ."" + .(($searchModel->hasErrors('date_add_from'))?'Дата начала не может быть больше сегодняшнего дня':'') + .(($searchModel->hasErrors('date_add_to'))?'Дата окончания должна быть больше даты начала':'')." ", 'format' => 'html', ], diff --git a/frontend/views/site/registration.php b/frontend/views/site/registration.php index a21d3f3..daf9553 100644 --- a/frontend/views/site/registration.php +++ b/frontend/views/site/registration.php @@ -1,11 +1,11 @@ -