diff --git a/common/models/Bookmark.php b/common/models/Bookmark.php new file mode 100644 index 0000000..641f987 --- /dev/null +++ b/common/models/Bookmark.php @@ -0,0 +1,67 @@ + 255], + [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'bookmark_id' => Yii::t('app', 'Bookmark ID'), + 'user_id' => Yii::t('app', 'User ID'), + 'model' => Yii::t('app', 'Model'), + 'model_id' => Yii::t('app', 'Model ID'), + 'type' => Yii::t('app', 'Type'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getUser() + { + return $this->hasOne(User::className(), ['id' => 'user_id']); + } +} diff --git a/common/models/Project.php b/common/models/Project.php index 1528a26..48df7c1 100644 --- a/common/models/Project.php +++ b/common/models/Project.php @@ -34,6 +34,7 @@ { public $files; + /** * @inheritdoc */ @@ -60,10 +61,10 @@ 'value' => new Expression('NOW()'), ], 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'name', + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', 'out_attribute' => 'link', - 'translit' => true + 'translit' => true ] ]; } @@ -75,7 +76,10 @@ { return [ [ - [ 'name', 'link' ], + [ + 'name', + 'link' + ], 'required', ], [ @@ -181,7 +185,6 @@ ->viaTable('project_payment', [ 'project_id' => 'project_id' ]); } - /** * @return \yii\db\ActiveQuery */ @@ -198,8 +201,6 @@ return $this->hasOne(self::className(), [ 'project_id' => 'project_pid' ]); } - - public function getBudgetCurrency() { return $this->hasOne(Currency::className(), [ 'currency_id' => 'budget_currency' ]); @@ -273,4 +274,9 @@ return [ ]; } } + + public function getIsBookmarked() + { + return false; + } } diff --git a/console/migrations/m160316_134249_bookmarks_table.php b/console/migrations/m160316_134249_bookmarks_table.php new file mode 100644 index 0000000..0629d40 --- /dev/null +++ b/console/migrations/m160316_134249_bookmarks_table.php @@ -0,0 +1,30 @@ +createTable('{{%bookmark}}', [ + 'bookmark_id' => $this->primaryKey(), + 'user_id' => $this->integer() + ->notNull(), + 'model' => $this->string() + ->notNull(), + 'model_id' => $this->integer() + ->notNull(), + 'type' => $this->integer() + ->notNull(), + ]); + $this->addForeignKey('bookmark_user', '{{%bookmark}}', 'user_id', '{{%user}}', 'id', 'CASCADE', 'CASCADE'); + } + + public function down() + { + $this->dropForeignKey('bookmark_user', '{{%bookmark}}'); + $this->dropTable('{{%bookmark}}'); + } + + } diff --git a/frontend/views/tender/view.php b/frontend/views/tender/view.php index a7bf457..8aed57e 100755 --- a/frontend/views/tender/view.php +++ b/frontend/views/tender/view.php @@ -65,7 +65,27 @@ $this->title = 'My Yii Application'; user->userInfo->social_vk}",['target'=>'_blank'])?> -
+ user->identity )) { + ?> +
+ isBookmarked) { + echo Html::a('', [ '#' ], [ + 'class' => 'artbox_bookmark_remove_performer', + 'data-id' => $model->project_id, + ]); + } else { + echo Html::a('', [ '#' ], [ + 'class' => 'artbox_bookmark_add_performer', + 'data-id' => $model->project_id, + ]); + } + ?> +
+
diff --git a/frontend/web/css/style.css b/frontend/web/css/style.css index 25ce3de..13301a8 100755 --- a/frontend/web/css/style.css +++ b/frontend/web/css/style.css @@ -1571,6 +1571,15 @@ input[type=file]::-webkit-file-upload-button { .performance-vacancy-add-favorite a.artbox_bookmark_remove_performer{ background: url("/images/button_add_fav_01.png") no-repeat; } +.performance-vacancy-add-favorite a.artbox_bookmark_remove_customer{ + background: url("/images/button_add_fav_01.png") no-repeat; +} +.performance-vacancy-add-favorite a.artbox_bookmark_remove_project{ + background: url("/images/button_add_fav_01.png") no-repeat; +} +.performance-vacancy-add-favorite a.artbox_bookmark_remove_vacancy{ + background: url("/images/button_add_fav_01.png") no-repeat; +} .performance-vacancy-add-favorite a:hover{opacity: 0.95} .menu-content-wr { height: 43px; diff --git a/frontend/web/images/button_add_fav_01.png b/frontend/web/images/button_add_fav_01.png new file mode 100644 index 0000000..4e8c890 Binary files /dev/null and b/frontend/web/images/button_add_fav_01.png differ -- libgit2 0.21.4