
diff --git a/.gitignore b/.gitignore index 562a2df..1387438 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ nbproject .buildpath .project .settings - +main-local.php # windows thumbnail cache Thumbs.db diff --git a/common/config/main.php b/common/config/main.php index cb2878a..bd1feec 100755 --- a/common/config/main.php +++ b/common/config/main.php @@ -26,6 +26,7 @@ ] ] ], + 'modules' => [ 'permit' => [ 'class' => 'common\components\developeruz\db_rbac\Yii2DbRbac', @@ -86,6 +87,7 @@ 'options', ], 'components' => [ + 'cache' => [ 'class' => 'yii\caching\FileCache', ], diff --git a/common/models/Chat.php b/common/models/Chat.php index 40abb9c..17fce86 100644 --- a/common/models/Chat.php +++ b/common/models/Chat.php @@ -19,6 +19,8 @@ use Yii; */ class Chat extends \yii\db\ActiveRecord { + public $newMessage; + /** * @inheritdoc */ @@ -75,6 +77,41 @@ class Chat extends \yii\db\ActiveRecord */ public function getMessages() { - return $this->hasMany(Message::className(), ['chat_id' => 'chat_id'])->orderBy('message_id') ; + return $this->hasMany(Message::className(), ['chat_id' => 'chat_id']) ; + + } + + + public function getAllMessages(){ + $messages = $this->hasMany(Message::className(), ['chat_id' => 'chat_id'])->orderBy('message_id'); + $messages_clone = clone($messages); + Message::updateAll(['status' => 0], ['message_id' => $messages->select(['message_id'])->where(['status' => 1])->column()]); + + return $messages_clone; + } + + + public function getInterlocutor(){ + if($this->from_user == \Yii::$app->user->id){ + return UserInfo::findOne(['user_id'=>$this->to_user]); + } else { + return UserInfo::findOne(['user_id'=>$this->from_user]); + } + } + + public function hasNewMessage(){ + $newMessages = $this->getMessages()->where(['status'=>'1', ]) + ->andWhere(['<>','user_id', \Yii::$app->user->id])->all(); + if($newMessages){ + + $this->newMessage = $newMessages; + + return true; + + } else { + return false; + } } + + } diff --git a/common/models/Job.php b/common/models/Job.php index 3a9f38c..8bb288a 100755 --- a/common/models/Job.php +++ b/common/models/Job.php @@ -28,6 +28,34 @@ class Job extends \yii\db\ActiveRecord return 'job'; } + + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'link', + 'translit' => true + ] + ]; + } + + public function beforeSave($insert) + { + $this->date_start = \Yii::$app->formatter->asDatetime($this->date_start, 'Y-MM-d HH:mm:ss'); + + if($this->date_end) { + $this->date_end = \Yii::$app->formatter->asDatetime($this->date_end, 'Y-MM-d HH:mm:ss'); + } + + + return parent::beforeSave($insert); // TODO: Change the autogenerated stub + } + /** * @inheritdoc */ diff --git a/common/models/Message.php b/common/models/Message.php index fa700fd..5a008da 100644 --- a/common/models/Message.php +++ b/common/models/Message.php @@ -23,6 +23,9 @@ class Message extends \yii\db\ActiveRecord public $file; + const NEW_MESSAGE = 1; + const READ_MESSAGE = 0; + /** * @inheritdoc */ @@ -40,6 +43,7 @@ class Message extends \yii\db\ActiveRecord [['chat_id', 'user_id', 'status'], 'integer'], [['text'], 'string'], [['date','file'], 'safe'], + [['status'], 'default', 'value' => self::NEW_MESSAGE], [['files'], 'string', 'max' => 255], [['chat_id'], 'exist', 'skipOnError' => true, 'targetClass' => Chat::className(), 'targetAttribute' => ['chat_id' => 'chat_id']], ]; @@ -76,7 +80,12 @@ class Message extends \yii\db\ActiveRecord public function getFilesList(){ $files = json_decode($this->files); - return File::findAll($files); + if(!empty($files)){ + return File::findAll($files); + } else { + return false; + } + } diff --git a/common/models/Project.php b/common/models/Project.php index b58dd36..9390d4d 100644 --- a/common/models/Project.php +++ b/common/models/Project.php @@ -41,6 +41,8 @@ return 'project'; } + + /** * @inheritdoc */ @@ -58,6 +60,12 @@ 'updatedAtAttribute' => false, 'value' => new Expression('NOW()'), ], + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'link', + 'translit' => true + ] ]; } diff --git a/common/models/Team.php b/common/models/Team.php index 48ac79e..631346a 100644 --- a/common/models/Team.php +++ b/common/models/Team.php @@ -34,6 +34,11 @@ return 'team'; } + + + + + /** * @inheritdoc */ @@ -51,6 +56,12 @@ 'updatedAtAttribute' => false, 'value' => new Expression('NOW()'), ], + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'link', + 'translit' => true + ] ]; } diff --git a/common/models/Vacancy.php b/common/models/Vacancy.php index fa8cb8e..1a30cfc 100644 --- a/common/models/Vacancy.php +++ b/common/models/Vacancy.php @@ -54,6 +54,12 @@ 'updatedAtAttribute' => false, 'value' => new Expression('NOW()'), ], + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'link', + 'translit' => true + ] ]; } @@ -72,10 +78,14 @@ 'string', ], [ - [ 'employmentInput', 'specializationInput' ], + [ 'employmentInput', 'specializationInput', ], 'safe', ], [ + ['salary_currency'], + 'integer' + ], + [ [ 'employmentInput', 'specializationInput' ], 'default', 'value' => [], diff --git a/common/widgets/views/youtube_field.php b/common/widgets/views/youtube_field.php index 3541550..f6abbb2 100644 --- a/common/widgets/views/youtube_field.php +++ b/common/widgets/views/youtube_field.php @@ -21,7 +21,7 @@ ]) ?>