36d1807a
Yarik
Big commit.
|
1
|
<?php
|
36d1807a
Yarik
Big commit.
|
2
|
|
cc658b4c
Yarik
Big commit
|
3
|
namespace common\models;
|
36d1807a
Yarik
Big commit.
|
4
|
|
af036678
Yarik
Image behaviors
|
5
6
|
use common\behaviors\MultipleImgBehavior;
use common\behaviors\SaveMultipleFileBehavior;
|
d55d2fe0
Yarik
Multilanguage
|
7
|
use common\modules\language\behaviors\LanguageBehavior;
|
cc658b4c
Yarik
Big commit
|
8
|
use common\modules\product\models\ProductVariant;
|
b569ac34
Eugeny Galkovskiy
MESSAGES !!!! EVGEN!
|
9
|
use Yii;
|
d55d2fe0
Yarik
Multilanguage
|
10
11
12
|
use yii\db\ActiveQuery;
use yii\db\ActiveRecord;
use yii\web\Request;
|
36d1807a
Yarik
Big commit.
|
13
14
|
/**
|
cc658b4c
Yarik
Big commit
|
15
|
* This is the model class for table "project".
|
72a992f5
Yarik
Import browser v1.0
|
16
|
* @todo Refactor
|
cc658b4c
Yarik
Big commit
|
17
|
* @property integer $project_id
|
cc658b4c
Yarik
Big commit
|
18
|
* @property integer $date_add
|
cc658b4c
Yarik
Big commit
|
19
20
21
|
* @property array $imagesConfig
* @property ProductVariant[] $variants
* @property ProductToProject[] $productToProject
|
d55d2fe0
Yarik
Multilanguage
|
22
23
24
25
26
27
|
* * From language behavior *
* @property ProjectLang $lang
* @property ProjectLang[] $langs
* @property ProjectLang $object_lang
* @property string $ownerKey
* @property string $langKey
|
72a992f5
Yarik
Import browser v1.0
|
28
29
|
* @property ProjectLang[] $model_langs
* @property bool $transactionStatus
|
d55d2fe0
Yarik
Multilanguage
|
30
31
32
33
34
35
36
|
* @method string getOwnerKey()
* @method void setOwnerKey( string $value )
* @method string getLangKey()
* @method void setLangKey( string $value )
* @method ActiveQuery getLangs()
* @method ActiveQuery getLang( integer $language_id )
* @method ProjectLang[] generateLangs()
|
72a992f5
Yarik
Import browser v1.0
|
37
38
39
40
|
* @method void loadLangs( Request $request )
* @method bool linkLangs()
* @method bool saveLangs()
* @method bool getTransactionStatus()
|
d55d2fe0
Yarik
Multilanguage
|
41
|
* * End language behavior *
|
af036678
Yarik
Image behaviors
|
42
43
44
45
46
47
48
49
|
* * From multipleImage behavior
* @property ProjectImage $image
* @property ProjectImage[] $images
* @method ActiveQuery getImage()
* @method ActiveQuery getImages()
* @method array getImagesConfig()
* @method array getImagesHTML( string $preset )
* * End multipleImage behavior
|
36d1807a
Yarik
Big commit.
|
50
|
*/
|
72a992f5
Yarik
Import browser v1.0
|
51
|
class Project extends ActiveRecord
|
36d1807a
Yarik
Big commit.
|
52
|
{
|
cc658b4c
Yarik
Big commit
|
53
54
55
56
57
58
59
60
61
|
public $imagesUpload = [];
/**
* @inheritdoc
*/
public static function tableName()
{
return 'project';
|
36d1807a
Yarik
Big commit.
|
62
|
}
|
cc658b4c
Yarik
Big commit
|
63
64
65
66
67
68
69
|
/**
* @inheritdoc
*/
public function behaviors()
{
return [
|
af036678
Yarik
Image behaviors
|
70
|
'language' => [
|
d55d2fe0
Yarik
Multilanguage
|
71
72
|
'class' => LanguageBehavior::className(),
],
|
af036678
Yarik
Image behaviors
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
'images' => [
'class' => SaveMultipleFileBehavior::className(),
'name' => 'imagesUpload',
'directory' => 'projects',
'column' => 'image',
'links' => [
'project_id' => 'project_id',
],
'model' => ProjectImage::className(),
],
'multipleImage' => [
'class' => MultipleImgBehavior::className(),
'links' => [
'project_id' => 'project_id',
],
'model' => ProjectImage::className(),
'config' => [
'caption' => 'image',
'delete_action' => '/project/delimg',
'id' => 'project_image_id',
],
],
|
cc658b4c
Yarik
Big commit
|
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[
[ 'date_add' ],
'default',
'value' => function() {
return time();
},
],
[
|
cc658b4c
Yarik
Big commit
|
112
113
114
|
[
'date_add',
'imagesUpload',
|
36d1807a
Yarik
Big commit.
|
115
|
],
|
cc658b4c
Yarik
Big commit
|
116
117
118
|
'safe',
],
[
|
cc658b4c
Yarik
Big commit
|
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
[ 'date_add' ],
'filter',
'filter' => function($value) {
return strtotime($value) ? : time();
},
],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
|
b569ac34
Eugeny Galkovskiy
MESSAGES !!!! EVGEN!
|
134
135
136
137
138
139
|
'project_id' => Yii::t('app', 'project_id'),
'title' => Yii::t('app', 'title'),
'link' => Yii::t('app', 'link'),
'description' => Yii::t('app', 'description'),
'date_add' => Yii::t('app', 'date_add'),
'images' => Yii::t('app', 'images'),
|
cc658b4c
Yarik
Big commit
|
140
141
142
|
];
}
|
cc658b4c
Yarik
Big commit
|
143
144
145
146
147
148
149
150
151
152
153
|
public function getProductToProject()
{
return $this->hasMany(ProductToProject::className(), [
'project_id' => 'project_id',
]);
}
public function getVariants()
{
return $this->hasMany(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ])
->viaTable('product_to_project', [ 'project_id' => 'project_id' ]);
|
36d1807a
Yarik
Big commit.
|
154
155
|
}
}
|