Commit cc4e7c12a841551f98acf2996d7af02195392bfc
1 parent
5077a0ec
test
Showing
6 changed files
with
140 additions
and
8 deletions
Show diff stats
1 | +<?php | |
2 | + | |
3 | +namespace common\models; | |
4 | + | |
5 | +use Yii; | |
6 | + | |
7 | +/** | |
8 | + * This is the model class for table "bookmark". | |
9 | + * | |
10 | + * @property integer $bookmark_id | |
11 | + * @property integer $user_id | |
12 | + * @property string $model | |
13 | + * @property integer $model_id | |
14 | + * @property integer $type | |
15 | + * | |
16 | + * @property User $user | |
17 | + */ | |
18 | +class Bookmark extends \yii\db\ActiveRecord | |
19 | +{ | |
20 | + | |
21 | + const TYPE_PERFORMER = 1; | |
22 | + const TYPE_CUSTOMER = 2; | |
23 | + const TYPE_PROJECT = 3; | |
24 | + const TYPE_VACANCY = 4; | |
25 | + /** | |
26 | + * @inheritdoc | |
27 | + */ | |
28 | + public static function tableName() | |
29 | + { | |
30 | + return 'bookmark'; | |
31 | + } | |
32 | + | |
33 | + /** | |
34 | + * @inheritdoc | |
35 | + */ | |
36 | + public function rules() | |
37 | + { | |
38 | + return [ | |
39 | + [['user_id', 'model', 'model_id', 'type'], 'required'], | |
40 | + [['user_id', 'model_id', 'type'], 'integer'], | |
41 | + [['model'], 'string', 'max' => 255], | |
42 | + [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']], | |
43 | + ]; | |
44 | + } | |
45 | + | |
46 | + /** | |
47 | + * @inheritdoc | |
48 | + */ | |
49 | + public function attributeLabels() | |
50 | + { | |
51 | + return [ | |
52 | + 'bookmark_id' => Yii::t('app', 'Bookmark ID'), | |
53 | + 'user_id' => Yii::t('app', 'User ID'), | |
54 | + 'model' => Yii::t('app', 'Model'), | |
55 | + 'model_id' => Yii::t('app', 'Model ID'), | |
56 | + 'type' => Yii::t('app', 'Type'), | |
57 | + ]; | |
58 | + } | |
59 | + | |
60 | + /** | |
61 | + * @return \yii\db\ActiveQuery | |
62 | + */ | |
63 | + public function getUser() | |
64 | + { | |
65 | + return $this->hasOne(User::className(), ['id' => 'user_id']); | |
66 | + } | |
67 | +} | ... | ... |
common/models/Project.php
... | ... | @@ -34,6 +34,7 @@ |
34 | 34 | { |
35 | 35 | |
36 | 36 | public $files; |
37 | + | |
37 | 38 | /** |
38 | 39 | * @inheritdoc |
39 | 40 | */ |
... | ... | @@ -60,10 +61,10 @@ |
60 | 61 | 'value' => new Expression('NOW()'), |
61 | 62 | ], |
62 | 63 | 'slug' => [ |
63 | - 'class' => 'common\behaviors\Slug', | |
64 | - 'in_attribute' => 'name', | |
64 | + 'class' => 'common\behaviors\Slug', | |
65 | + 'in_attribute' => 'name', | |
65 | 66 | 'out_attribute' => 'link', |
66 | - 'translit' => true | |
67 | + 'translit' => true | |
67 | 68 | ] |
68 | 69 | ]; |
69 | 70 | } |
... | ... | @@ -75,7 +76,10 @@ |
75 | 76 | { |
76 | 77 | return [ |
77 | 78 | [ |
78 | - [ 'name', 'link' ], | |
79 | + [ | |
80 | + 'name', | |
81 | + 'link' | |
82 | + ], | |
79 | 83 | 'required', |
80 | 84 | ], |
81 | 85 | [ |
... | ... | @@ -181,7 +185,6 @@ |
181 | 185 | ->viaTable('project_payment', [ 'project_id' => 'project_id' ]); |
182 | 186 | } |
183 | 187 | |
184 | - | |
185 | 188 | /** |
186 | 189 | * @return \yii\db\ActiveQuery |
187 | 190 | */ |
... | ... | @@ -198,8 +201,6 @@ |
198 | 201 | return $this->hasOne(self::className(), [ 'project_id' => 'project_pid' ]); |
199 | 202 | } |
200 | 203 | |
201 | - | |
202 | - | |
203 | 204 | public function getBudgetCurrency() |
204 | 205 | { |
205 | 206 | return $this->hasOne(Currency::className(), [ 'currency_id' => 'budget_currency' ]); |
... | ... | @@ -273,4 +274,9 @@ |
273 | 274 | return [ ]; |
274 | 275 | } |
275 | 276 | } |
277 | + | |
278 | + public function getIsBookmarked() | |
279 | + { | |
280 | + return false; | |
281 | + } | |
276 | 282 | } | ... | ... |
console/migrations/m160316_134249_bookmarks_table.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | + use yii\db\Migration; | |
4 | + | |
5 | + class m160316_134249_bookmarks_table extends Migration | |
6 | + { | |
7 | + | |
8 | + public function up() | |
9 | + { | |
10 | + $this->createTable('{{%bookmark}}', [ | |
11 | + 'bookmark_id' => $this->primaryKey(), | |
12 | + 'user_id' => $this->integer() | |
13 | + ->notNull(), | |
14 | + 'model' => $this->string() | |
15 | + ->notNull(), | |
16 | + 'model_id' => $this->integer() | |
17 | + ->notNull(), | |
18 | + 'type' => $this->integer() | |
19 | + ->notNull(), | |
20 | + ]); | |
21 | + $this->addForeignKey('bookmark_user', '{{%bookmark}}', 'user_id', '{{%user}}', 'id', 'CASCADE', 'CASCADE'); | |
22 | + } | |
23 | + | |
24 | + public function down() | |
25 | + { | |
26 | + $this->dropForeignKey('bookmark_user', '{{%bookmark}}'); | |
27 | + $this->dropTable('{{%bookmark}}'); | |
28 | + } | |
29 | + | |
30 | + } | ... | ... |
frontend/views/tender/view.php
... | ... | @@ -65,7 +65,27 @@ $this->title = 'My Yii Application'; |
65 | 65 | <?= Html::a(Html::img('/images/ico-vk.png'),"{$model->user->userInfo->social_vk}",['target'=>'_blank'])?> |
66 | 66 | </div> |
67 | 67 | </div> |
68 | - <div class="performance-vacancy-add-favorite"><a href="#"></a></div> | |
68 | + <?php | |
69 | + if(!empty( \Yii::$app->user->identity )) { | |
70 | + ?> | |
71 | + <div class="performance-vacancy-add-favorite"> | |
72 | + <?php | |
73 | + if($model->isBookmarked) { | |
74 | + echo Html::a('', [ '#' ], [ | |
75 | + 'class' => 'artbox_bookmark_remove_performer', | |
76 | + 'data-id' => $model->project_id, | |
77 | + ]); | |
78 | + } else { | |
79 | + echo Html::a('', [ '#' ], [ | |
80 | + 'class' => 'artbox_bookmark_add_performer', | |
81 | + 'data-id' => $model->project_id, | |
82 | + ]); | |
83 | + } | |
84 | + ?> | |
85 | + </div> | |
86 | + <?php | |
87 | + } | |
88 | + ?> | |
69 | 89 | <div class="cab-mes-read-last-visit"> |
70 | 90 | <div class="cab-mes-read-min-bl" style="width: 204px"> |
71 | 91 | <div class="profile-phone-site style"> | ... | ... |
frontend/web/css/style.css
... | ... | @@ -1571,6 +1571,15 @@ input[type=file]::-webkit-file-upload-button { |
1571 | 1571 | .performance-vacancy-add-favorite a.artbox_bookmark_remove_performer{ |
1572 | 1572 | background: url("/images/button_add_fav_01.png") no-repeat; |
1573 | 1573 | } |
1574 | +.performance-vacancy-add-favorite a.artbox_bookmark_remove_customer{ | |
1575 | + background: url("/images/button_add_fav_01.png") no-repeat; | |
1576 | +} | |
1577 | +.performance-vacancy-add-favorite a.artbox_bookmark_remove_project{ | |
1578 | + background: url("/images/button_add_fav_01.png") no-repeat; | |
1579 | +} | |
1580 | +.performance-vacancy-add-favorite a.artbox_bookmark_remove_vacancy{ | |
1581 | + background: url("/images/button_add_fav_01.png") no-repeat; | |
1582 | +} | |
1574 | 1583 | .performance-vacancy-add-favorite a:hover{opacity: 0.95} |
1575 | 1584 | .menu-content-wr { |
1576 | 1585 | height: 43px; | ... | ... |
19.3 KB