1 | <?php |
||
46 | class Issue extends BaseModel |
||
47 | { |
||
48 | use CountAttributeTrait, |
||
49 | CountTrait, |
||
50 | CrudTrait, |
||
51 | CrudTagTrait, |
||
52 | RelationTrait, |
||
53 | QueryTrait, |
||
54 | QueueTrait; |
||
55 | |||
56 | /** |
||
57 | * Issue status: Open. |
||
58 | * |
||
59 | * @var int |
||
60 | */ |
||
61 | const STATUS_OPEN = 1; |
||
62 | |||
63 | /** |
||
64 | * Issue status: Closed. |
||
65 | * |
||
66 | * @var int |
||
67 | */ |
||
68 | const STATUS_CLOSED = 0; |
||
69 | |||
70 | /** |
||
71 | * Timestamp enabled. |
||
72 | * |
||
73 | * @var bool |
||
74 | */ |
||
75 | public $timestamps = true; |
||
76 | |||
77 | /** |
||
78 | * Name of database table. |
||
79 | * |
||
80 | * @var string |
||
81 | */ |
||
82 | protected $table = 'projects_issues'; |
||
83 | |||
84 | /** |
||
85 | * List of allowed columns to be used in $this->fill(). |
||
86 | * |
||
87 | * @var array |
||
88 | */ |
||
89 | protected $fillable = ['created_by', 'project_id', 'title', 'body', 'assigned_to', 'time_quote', 'lock_quote']; |
||
90 | |||
91 | /** |
||
92 | * Set attributes default value. |
||
93 | * |
||
94 | * @var array |
||
95 | */ |
||
96 | protected $attributes = [ |
||
97 | 'status' => self::STATUS_OPEN, |
||
98 | ]; |
||
99 | |||
100 | /** |
||
101 | * Returns the aggregate value of number of comments in an issue. |
||
102 | * |
||
103 | * @return int |
||
104 | */ |
||
105 | 6 | public function getCountCommentsAttribute() |
|
106 | { |
||
107 | 6 | return $this->getCountAttribute('countComments'); |
|
108 | } |
||
109 | |||
110 | /** |
||
111 | * Generate a URL for the active project. |
||
112 | * |
||
113 | * @param string $url |
||
114 | * |
||
115 | * @return string |
||
116 | */ |
||
117 | 29 | public function to($url = '') |
|
118 | { |
||
119 | 29 | return \URL::to('project/' . $this->project_id . '/issue/' . $this->id . (($url) ? '/' . $url : '')); |
|
120 | } |
||
121 | |||
122 | /** |
||
123 | * Convert time quote from an array into seconds. |
||
124 | * |
||
125 | * @param array $value |
||
126 | */ |
||
127 | 33 | public function setTimeQuoteAttribute($value) |
|
128 | { |
||
129 | 33 | $seconds = $value; |
|
130 | 33 | if (is_array($value)) { |
|
131 | 32 | $seconds = 0; |
|
132 | 32 | $seconds += isset($value['m']) ? ($value['m'] * 60) : 0; |
|
133 | 32 | $seconds += isset($value['h']) ? ($value['h'] * 60 * 60) : 0; |
|
134 | } |
||
135 | 33 | $this->attributes['time_quote'] = (int) $seconds; |
|
136 | 33 | } |
|
137 | |||
138 | /** |
||
139 | * Returns the color of tag status. |
||
140 | * |
||
141 | * @return string |
||
142 | */ |
||
143 | public function getTypeColorAttribute() |
||
155 | |||
156 | /** |
||
157 | * Whether or not the issue is new. |
||
158 | * |
||
159 | * @return bool |
||
160 | */ |
||
161 | public function isNew() |
||
169 | |||
170 | /** |
||
171 | * Whether or not the issue is open or closed. |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | 25 | public function isOpen() |
|
179 | |||
180 | /** |
||
181 | * Check if the issue contains a tag with option to set the issue as readonly to current user. |
||
182 | * |
||
183 | * @param Model\User $user |
||
184 | * |
||
185 | * @return bool |
||
186 | */ |
||
187 | 2 | public function hasReadOnlyTag(Model\User $user) |
|
193 | |||
194 | /** |
||
195 | * Whether or not the issue quote is locked by manager. |
||
196 | * |
||
197 | * @return bool |
||
198 | */ |
||
199 | 9 | public function isQuoteLocked() |
|
203 | |||
204 | /** |
||
205 | * Check if a user is allowed to see the issue quote. |
||
206 | * |
||
207 | * @param Model\User $user |
||
208 | * |
||
209 | * @return bool |
||
210 | */ |
||
211 | 23 | public function canUserViewQuote(Model\User $user = null) |
|
221 | |||
222 | /** |
||
223 | * Whether or not a user is the creator of the issue. |
||
224 | * |
||
225 | * @param Model\User $user |
||
226 | * |
||
227 | * @return bool |
||
228 | */ |
||
229 | public function isCreatedBy(Model\User $user) |
||
233 | } |
||
234 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.