|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace common\models; |
|
4
|
|
|
|
|
5
|
|
|
use Yii; |
|
6
|
|
|
use yii\helpers\ArrayHelper as AH; |
|
7
|
|
|
use \common\interfaces\BehaviorInterface; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @property integer $id |
|
11
|
|
|
* @property string $name |
|
12
|
|
|
* @property integer $category_id |
|
13
|
|
|
*/ |
|
14
|
|
|
class Behavior extends \yii\base\BaseObject implements BehaviorInterface |
|
15
|
|
|
{ |
|
16
|
|
|
public static $behaviors = [ |
|
17
|
|
|
['id' => 1, 'name' => 'no current secrets', 'category_id' => 1], |
|
18
|
|
|
['id' => 2, 'name' => 'resolving problems', 'category_id' => 1], |
|
19
|
|
|
['id' => 3, 'name' => 'identifying fears and feelings', 'category_id' => 1], |
|
20
|
|
|
['id' => 4, 'name' => 'keeping commitments to meetings, prayer, family, church, people, goals, and self', 'category_id' => 1], |
|
21
|
|
|
['id' => 5, 'name' => 'being open', 'category_id' => 1], |
|
22
|
|
|
['id' => 6, 'name' => 'being honest', 'category_id' => 1], |
|
23
|
|
|
['id' => 7, 'name' => 'making eye contact', 'category_id' => 1], |
|
24
|
|
|
['id' => 8, 'name' => 'reaching out to others', 'category_id' => 1], |
|
25
|
|
|
['id' => 9, 'name' => 'increasing in relationships with God and others', 'category_id' => 1], |
|
26
|
|
|
['id' => 10, 'name' => 'accountability', 'category_id' => 1], |
|
27
|
|
|
['id' => 11, 'name' => 'secrets', 'category_id' => 2], |
|
28
|
|
|
['id' => 12, 'name' => 'bored', 'category_id' => 2], |
|
29
|
|
|
['id' => 13, 'name' => 'less time/energy for God, meetings, and church', 'category_id' => 2], |
|
30
|
|
|
['id' => 14, 'name' => 'avoiding support and accountability towards people', 'category_id' => 2], |
|
31
|
|
|
['id' => 15, 'name' => 'superficial conversations', 'category_id' => 2], |
|
32
|
|
|
['id' => 16, 'name' => 'sarcasm', 'category_id' => 2], |
|
33
|
|
|
['id' => 17, 'name' => 'isolating yourself', 'category_id' => 2], |
|
34
|
|
|
['id' => 18, 'name' => 'changes in goals', 'category_id' => 2], |
|
35
|
|
|
['id' => 19, 'name' => 'flirting', 'category_id' => 2], |
|
36
|
|
|
['id' => 20, 'name' => 'obsessed with relationships', 'category_id' => 2], |
|
37
|
|
|
['id' => 21, 'name' => 'breaking promises/commitments', 'category_id' => 2], |
|
38
|
|
|
['id' => 22, 'name' => 'neglecting family', 'category_id' => 2], |
|
39
|
|
|
['id' => 23, 'name' => 'preoccupation with material things, television, or entertainment', 'category_id' => 2], |
|
40
|
|
|
['id' => 24, 'name' => 'procrastination', 'category_id' => 2], |
|
41
|
|
|
['id' => 25, 'name' => 'lying', 'category_id' => 2], |
|
42
|
|
|
['id' => 26, 'name' => 'over-confidence', 'category_id' => 2], |
|
43
|
|
|
['id' => 27, 'name' => 'hiding money', 'category_id' => 2], |
|
44
|
|
|
['id' => 28, 'name' => 'worry', 'category_id' => 3], |
|
45
|
|
|
['id' => 29, 'name' => 'using profanity', 'category_id' => 3], |
|
46
|
|
|
['id' => 30, 'name' => 'being fearful', 'category_id' => 3], |
|
47
|
|
|
['id' => 31, 'name' => 'being resentful', 'category_id' => 3], |
|
48
|
|
|
['id' => 32, 'name' => 'replaying old, negative thoughts', 'category_id' => 3], |
|
49
|
|
|
['id' => 33, 'name' => 'perfectionism', 'category_id' => 3], |
|
50
|
|
|
['id' => 34, 'name' => 'judging others\' motives', 'category_id' => 3], |
|
51
|
|
|
['id' => 35, 'name' => 'making goals and lists you can\'t complete', 'category_id' => 3], |
|
52
|
|
|
['id' => 36, 'name' => 'poor planning', 'category_id' => 3], |
|
53
|
|
|
['id' => 37, 'name' => 'mind reading', 'category_id' => 3], |
|
54
|
|
|
['id' => 38, 'name' => 'fantasy', 'category_id' => 3], |
|
55
|
|
|
['id' => 41, 'name' => 'co-dependent rescuing', 'category_id' => 3], |
|
56
|
|
|
['id' => 42, 'name' => 'sleep problems', 'category_id' => 3], |
|
57
|
|
|
['id' => 43, 'name' => 'trouble concentrating', 'category_id' => 3], |
|
58
|
|
|
['id' => 44, 'name' => 'seeking/creating drama', 'category_id' => 3], |
|
59
|
|
|
['id' => 45, 'name' => 'gossip', 'category_id' => 3], |
|
60
|
|
|
['id' => 46, 'name' => 'using over-the-counter medication for pain, sleep, and weight control', 'category_id' => 3], |
|
61
|
|
|
['id' => 47, 'name' => 'super busy', 'category_id' => 4], |
|
62
|
|
|
['id' => 48, 'name' => 'workaholic', 'category_id' => 4], |
|
63
|
|
|
['id' => 49, 'name' => 'can\'t relax', 'category_id' => 4], |
|
64
|
|
|
['id' => 50, 'name' => 'driving too fast', 'category_id' => 4], |
|
65
|
|
|
['id' => 51, 'name' => 'avoiding slowing down', 'category_id' => 4], |
|
66
|
|
|
['id' => 52, 'name' => 'feeling driven', 'category_id' => 4], |
|
67
|
|
|
['id' => 53, 'name' => 'in a hurry', 'category_id' => 4], |
|
68
|
|
|
['id' => 54, 'name' => 'can\'t turn off thoughts', 'category_id' => 4], |
|
69
|
|
|
['id' => 55, 'name' => 'skipping meals', 'category_id' => 4], |
|
70
|
|
|
['id' => 56, 'name' => 'binge eating (usually at night)', 'category_id' => 4], |
|
71
|
|
|
['id' => 57, 'name' => 'overspending', 'category_id' => 4], |
|
72
|
|
|
['id' => 58, 'name' => 'can\'t identify own feelings/needs', 'category_id' => 4], |
|
73
|
|
|
['id' => 59, 'name' => 'repetitive, negative thoughts', 'category_id' => 4], |
|
74
|
|
|
['id' => 60, 'name' => 'irritable', 'category_id' => 4], |
|
75
|
|
|
['id' => 61, 'name' => 'making excuses for "having to do it all"', 'category_id' => 4], |
|
76
|
|
|
['id' => 62, 'name' => 'dramatic mood swings', 'category_id' => 4], |
|
77
|
|
|
['id' => 63, 'name' => 'lust', 'category_id' => 4], |
|
78
|
|
|
['id' => 64, 'name' => 'too much caffeine', 'category_id' => 4], |
|
79
|
|
|
['id' => 65, 'name' => 'over exercising', 'category_id' => 4], |
|
80
|
|
|
['id' => 66, 'name' => 'nervousness', 'category_id' => 4], |
|
81
|
|
|
['id' => 67, 'name' => 'difficulty being alone or with people', 'category_id' => 4], |
|
82
|
|
|
['id' => 68, 'name' => 'difficulty listening to others', 'category_id' => 4], |
|
83
|
|
|
['id' => 69, 'name' => 'avoiding support', 'category_id' => 4], |
|
84
|
|
|
['id' => 70, 'name' => 'procrastination causing crises in money, work, or relationships', 'category_id' => 5], |
|
85
|
|
|
['id' => 71, 'name' => 'sarcasm', 'category_id' => 5], |
|
86
|
|
|
['id' => 72, 'name' => 'black and white, all or nothing thinking', 'category_id' => 5], |
|
87
|
|
|
['id' => 73, 'name' => 'feeling that no one understands', 'category_id' => 5], |
|
88
|
|
|
['id' => 74, 'name' => 'overreacting', 'category_id' => 5], |
|
89
|
|
|
['id' => 75, 'name' => 'road rage', 'category_id' => 5], |
|
90
|
|
|
['id' => 76, 'name' => 'constant resentments', 'category_id' => 5], |
|
91
|
|
|
['id' => 77, 'name' => 'pushing others away', 'category_id' => 5], |
|
92
|
|
|
['id' => 78, 'name' => 'increased isolation', 'category_id' => 5], |
|
93
|
|
|
['id' => 79, 'name' => 'blaming', 'category_id' => 5], |
|
94
|
|
|
['id' => 80, 'name' => 'self pity', 'category_id' => 5], |
|
95
|
|
|
['id' => 81, 'name' => 'arguing', 'category_id' => 5], |
|
96
|
|
|
['id' => 82, 'name' => 'irrationality', 'category_id' => 5], |
|
97
|
|
|
['id' => 83, 'name' => 'can\'t handle criticism', 'category_id' => 5], |
|
98
|
|
|
['id' => 84, 'name' => 'defensive', 'category_id' => 5], |
|
99
|
|
|
['id' => 85, 'name' => 'people are avoiding you', 'category_id' => 5], |
|
100
|
|
|
['id' => 86, 'name' => 'having to be right', 'category_id' => 5], |
|
101
|
|
|
['id' => 87, 'name' => 'digestive problems', 'category_id' => 5], |
|
102
|
|
|
['id' => 88, 'name' => 'headaches', 'category_id' => 5], |
|
103
|
|
|
['id' => 89, 'name' => 'obsessive (stuck) thoughts', 'category_id' => 5], |
|
104
|
|
|
['id' => 90, 'name' => 'can\'t forgive', 'category_id' => 5], |
|
105
|
|
|
['id' => 91, 'name' => 'feeling grandiose (superior)', 'category_id' => 5], |
|
106
|
|
|
['id' => 92, 'name' => 'intimidation', 'category_id' => 5], |
|
107
|
|
|
['id' => 93, 'name' => 'feeling aggressive', 'category_id' => 5], |
|
108
|
|
|
['id' => 94, 'name' => 'depressed', 'category_id' => 6], |
|
109
|
|
|
['id' => 95, 'name' => 'panicked', 'category_id' => 6], |
|
110
|
|
|
['id' => 96, 'name' => 'confused', 'category_id' => 6], |
|
111
|
|
|
['id' => 97, 'name' => 'hopeless', 'category_id' => 6], |
|
112
|
|
|
['id' => 98, 'name' => 'sleeping too much or too little', 'category_id' => 6], |
|
113
|
|
|
['id' => 99, 'name' => 'can\'t cope', 'category_id' => 6], |
|
114
|
|
|
['id' => 100, 'name' => 'overwhelmed', 'category_id' => 6], |
|
115
|
|
|
['id' => 101, 'name' => 'crying for "no reason"', 'category_id' => 6], |
|
116
|
|
|
['id' => 102, 'name' => 'can\'t think', 'category_id' => 6], |
|
117
|
|
|
['id' => 103, 'name' => 'forgetful', 'category_id' => 6], |
|
118
|
|
|
['id' => 104, 'name' => 'pessimistic', 'category_id' => 6], |
|
119
|
|
|
['id' => 105, 'name' => 'helpless', 'category_id' => 6], |
|
120
|
|
|
['id' => 106, 'name' => 'tired', 'category_id' => 6], |
|
121
|
|
|
['id' => 107, 'name' => 'numb', 'category_id' => 6], |
|
122
|
|
|
['id' => 108, 'name' => 'wanting to run', 'category_id' => 6], |
|
123
|
|
|
['id' => 109, 'name' => 'constant cravings for old coping behaviors', 'category_id' => 6], |
|
124
|
|
|
['id' => 110, 'name' => 'thinking of using porn, sex, drugs, or alcohol', 'category_id' => 6], |
|
125
|
|
|
['id' => 111, 'name' => 'seeking out old unhealthy people and places', 'category_id' => 6], |
|
126
|
|
|
['id' => 112, 'name' => 'really isolated', 'category_id' => 6], |
|
127
|
|
|
['id' => 113, 'name' => 'people are angry with you', 'category_id' => 6], |
|
128
|
|
|
['id' => 114, 'name' => 'self-abuse', 'category_id' => 6], |
|
129
|
|
|
['id' => 115, 'name' => 'suicidal thoughts', 'category_id' => 6], |
|
130
|
|
|
['id' => 116, 'name' => 'no goals', 'category_id' => 6], |
|
131
|
|
|
['id' => 117, 'name' => 'survival mode', 'category_id' => 6], |
|
132
|
|
|
['id' => 118, 'name' => 'not returning phone calls', 'category_id' => 6], |
|
133
|
|
|
['id' => 119, 'name' => 'missing work', 'category_id' => 6], |
|
134
|
|
|
['id' => 120, 'name' => 'irritability', 'category_id' => 6], |
|
135
|
|
|
['id' => 121, 'name' => 'loss of appetite', 'category_id' => 6], |
|
136
|
|
|
['id' => 122, 'name' => 'returning to the place you swore you would never go again', 'category_id' => 7], |
|
137
|
|
|
['id' => 123, 'name' => 'giving up', 'category_id' => 7], |
|
138
|
|
|
['id' => 124, 'name' => 'giving in', 'category_id' => 7], |
|
139
|
|
|
['id' => 125, 'name' => 'out of control', 'category_id' => 7], |
|
140
|
|
|
['id' => 126, 'name' => 'lost in your addiction', 'category_id' => 7], |
|
141
|
|
|
['id' => 127, 'name' => 'lying to yourself and others', 'category_id' => 7], |
|
142
|
|
|
['id' => 128, 'name' => 'feeling you just can\'t manage without your coping behavior, at least for now', 'category_id' => 7], |
|
143
|
|
|
['id' => 129, 'name' => 'shame', 'category_id' => 7], |
|
144
|
|
|
['id' => 130, 'name' => 'condemnation', 'category_id' => 7], |
|
145
|
|
|
['id' => 131, 'name' => 'guilt', 'category_id' => 7], |
|
146
|
|
|
['id' => 132, 'name' => 'aloneness', 'category_id' => 7], |
|
147
|
|
|
]; |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @inheritdoc |
|
151
|
|
|
* @codeCoverageIgnore |
|
152
|
|
|
*/ |
|
153
|
|
|
public function rules() |
|
154
|
|
|
{ |
|
155
|
|
|
return [ |
|
156
|
|
|
[['name', 'category_id'], 'required'], |
|
157
|
|
|
[['name'], 'string'], |
|
158
|
|
|
[['category_id'], 'integer'] |
|
159
|
|
|
]; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @inheritdoc |
|
164
|
|
|
* @codeCoverageIgnore |
|
165
|
|
|
*/ |
|
166
|
|
|
public function attributeLabels() |
|
167
|
|
|
{ |
|
168
|
|
|
return [ |
|
169
|
|
|
'id' => 'ID', |
|
170
|
|
|
'name' => 'Name', |
|
171
|
|
|
'category_id' => 'Category ID', |
|
172
|
|
|
]; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/** |
|
176
|
|
|
* This grabs all the categories from Category and adds the count of |
|
177
|
|
|
* behaviors in each category, it also renames the "id" field to be |
|
178
|
|
|
* "category_id". |
|
179
|
|
|
* |
|
180
|
|
|
* @returns Array |
|
181
|
|
|
*/ |
|
182
|
|
|
public function getCategories() { |
|
183
|
|
|
$bhvrs_by_cat = AH::index(self::$behaviors, null, 'category_id'); |
|
184
|
|
|
$cats = AH::index(\common\models\Category::$categories, "id"); |
|
185
|
|
|
foreach($cats as $id => &$cat) { |
|
186
|
|
|
$cat['behavior_count'] = count($bhvrs_by_cat[$id]); // add count of behaviors |
|
187
|
|
|
$cat['category_id'] = $cat['id']; // rename id to category_id |
|
188
|
|
|
unset($cat['id']); |
|
189
|
|
|
} |
|
190
|
|
|
return $cats; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* |
|
195
|
|
|
/** |
|
196
|
|
|
* Given a $key => $value pair, returns the matching behavior. |
|
197
|
|
|
* Example: |
|
198
|
|
|
* getBehavior('id', 1); |
|
199
|
|
|
* Should return: |
|
200
|
|
|
* ['id' => 1, 'name' => 'no current secrets', 'category_id' => 1] |
|
201
|
|
|
* |
|
202
|
|
|
* @param string $key the name of the attribute to filter on |
|
203
|
|
|
* @param string $val the value of the attribute to filter on |
|
204
|
|
|
* @return a single behavior |
|
|
|
|
|
|
205
|
|
|
*/ |
|
206
|
|
|
public static function getBehavior($key, $val) { |
|
207
|
|
|
$ret = array_values(array_filter(self::$behaviors, function($bvr) use ($key, $val) { |
|
208
|
|
|
return $bvr[$key] === $val; |
|
209
|
|
|
})); |
|
210
|
|
|
return $ret ? $ret[0] : null; |
|
211
|
|
|
} |
|
212
|
|
|
} |
|
213
|
|
|
|