1 | <?php |
||
44 | class Issue extends BaseModel |
||
45 | { |
||
46 | use CountAttributeTrait, |
||
47 | CountTrait, |
||
48 | CrudTrait, |
||
49 | CrudTagTrait, |
||
50 | RelationTrait, |
||
51 | QueryTrait; |
||
52 | |||
53 | /** |
||
54 | * Issue status: Open. |
||
55 | * |
||
56 | * @var int |
||
57 | */ |
||
58 | const STATUS_OPEN = 1; |
||
59 | |||
60 | /** |
||
61 | * Issue status: Closed. |
||
62 | * |
||
63 | * @var int |
||
64 | */ |
||
65 | const STATUS_CLOSED = 0; |
||
66 | |||
67 | /** |
||
68 | * Timestamp enabled. |
||
69 | * |
||
70 | * @var bool |
||
71 | */ |
||
72 | public $timestamps = true; |
||
73 | |||
74 | /** |
||
75 | * Name of database table. |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | protected $table = 'projects_issues'; |
||
80 | |||
81 | /** |
||
82 | * List of allowed columns to be used in $this->fill(). |
||
83 | * |
||
84 | * @var array |
||
85 | */ |
||
86 | protected $fillable = ['created_by', 'project_id', 'title', 'body', 'assigned_to', 'time_quote']; |
||
87 | |||
88 | /** |
||
89 | * Returns the aggregate value of number of comments in an issue. |
||
90 | * |
||
91 | * @return int |
||
92 | */ |
||
93 | 6 | public function getCountCommentsAttribute() |
|
94 | { |
||
95 | 6 | return $this->getCountAttribute('countComments'); |
|
96 | } |
||
97 | |||
98 | /** |
||
99 | * Generate a URL for the active project. |
||
100 | * |
||
101 | * @param string $url |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | 25 | public function to($url = '') |
|
106 | { |
||
107 | 25 | return \URL::to('project/' . $this->project_id . '/issue/' . $this->id . (($url) ? '/' . $url : '')); |
|
108 | } |
||
109 | |||
110 | /** |
||
111 | * Convert time quote from an array into seconds. |
||
112 | * |
||
113 | * @param array $value |
||
114 | */ |
||
115 | 27 | public function setTimeQuoteAttribute($value) |
|
116 | { |
||
117 | 27 | $seconds = $value; |
|
118 | 27 | if (is_array($value)) { |
|
119 | 26 | $seconds = 0; |
|
120 | 26 | $seconds += isset($value['m']) ? ($value['m'] * 60) : 0; |
|
121 | 26 | $seconds += isset($value['h']) ? ($value['h'] * 60 * 60) : 0; |
|
122 | } |
||
123 | 27 | $this->attributes['time_quote'] = (int) $seconds; |
|
124 | 27 | } |
|
125 | |||
126 | /** |
||
127 | * Returns the color of tag status. |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | public function getTypeColorAttribute() |
||
143 | |||
144 | /** |
||
145 | * Whether or not the issue is new. |
||
146 | * |
||
147 | * @return bool |
||
148 | */ |
||
149 | 16 | public function isNew() |
|
157 | |||
158 | /** |
||
159 | * Whether or not the issue is open or closed. |
||
160 | * |
||
161 | * @return bool |
||
162 | */ |
||
163 | 2 | public function isOpen() |
|
167 | } |
||
168 |
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.