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'; = Html::a(Html::img('/images/ico-vk.png'),"{$model->user->userInfo->social_vk}",['target'=>'_blank'])?> -
+ user->identity )) { + ?> +