1 | <?php |
||
69 | class Project extends ModelAbstract |
||
70 | { |
||
71 | use ProjectRelations, |
||
72 | ProjectScopes; |
||
73 | |||
74 | /** |
||
75 | * Project private & user role can see their own issues only. |
||
76 | * |
||
77 | * @var int |
||
78 | */ |
||
79 | const INTERNAL_YES = 2; |
||
80 | |||
81 | /** |
||
82 | * Project not public to view and create issue. |
||
83 | * |
||
84 | * @var int |
||
85 | */ |
||
86 | const PRIVATE_YES = 1; |
||
87 | |||
88 | /** |
||
89 | * Project public to view and create issue. |
||
90 | * |
||
91 | * @var int |
||
92 | */ |
||
93 | const PRIVATE_NO = 0; |
||
94 | |||
95 | /** |
||
96 | * All projects. |
||
97 | * |
||
98 | * @var int |
||
99 | */ |
||
100 | const PRIVATE_ALL = -1; |
||
101 | |||
102 | /** |
||
103 | * Project status Open. |
||
104 | * |
||
105 | * @var int |
||
106 | */ |
||
107 | const STATUS_OPEN = 1; |
||
108 | |||
109 | /** |
||
110 | * Project status Archived. |
||
111 | * |
||
112 | * @var int |
||
113 | */ |
||
114 | const STATUS_ARCHIVED = 0; |
||
115 | |||
116 | /** |
||
117 | * Timestamp enabled. |
||
118 | * |
||
119 | * @var bool |
||
120 | */ |
||
121 | public $timestamps = true; |
||
122 | |||
123 | /** |
||
124 | * Name of database table. |
||
125 | * |
||
126 | * @var string |
||
127 | */ |
||
128 | protected $table = 'projects'; |
||
129 | |||
130 | /** |
||
131 | * List of allowed columns to be used in $this->fill(). |
||
132 | * |
||
133 | * @var array |
||
134 | */ |
||
135 | protected $fillable = ['name', 'default_assignee', 'status', 'private']; |
||
136 | |||
137 | /** |
||
138 | * List of HTML classes for each status. |
||
139 | * |
||
140 | * @var array |
||
141 | */ |
||
142 | protected $attrClassNames = [ |
||
143 | self::PRIVATE_NO => 'note', |
||
144 | self::PRIVATE_YES => 'info', |
||
145 | self::INTERNAL_YES => 'primary', |
||
146 | ]; |
||
147 | |||
148 | /** |
||
149 | * List of statuses names. |
||
150 | * |
||
151 | * @var array |
||
152 | */ |
||
153 | protected $statusesNames = [ |
||
154 | self::PRIVATE_NO => 'public', |
||
155 | self::PRIVATE_YES => 'private', |
||
156 | self::INTERNAL_YES => 'internal', |
||
157 | ]; |
||
158 | |||
159 | /** |
||
160 | * @param User|null $user |
||
161 | * |
||
162 | * @return \Tinyissue\Repository\Project\Updater |
||
163 | */ |
||
164 | public function updater(User $user = null) |
||
168 | |||
169 | /** |
||
170 | * Generate a URL for the active project. |
||
171 | * |
||
172 | * @param string $url |
||
173 | * |
||
174 | * @return string |
||
175 | */ |
||
176 | public function to($url = '') |
||
180 | |||
181 | /** |
||
182 | * Returns the aggregate value of number of open issues in the project. |
||
183 | * |
||
184 | * @return int |
||
185 | */ |
||
186 | public function getOpenIssuesCountAttribute() |
||
190 | |||
191 | /** |
||
192 | * Returns the aggregate value of number of closed issues in the project. |
||
193 | * |
||
194 | * @return int |
||
195 | */ |
||
196 | public function getClosedIssuesCountAttribute() |
||
200 | |||
201 | /** |
||
202 | * Set default assignee attribute. |
||
203 | * |
||
204 | * @param int $value |
||
205 | * |
||
206 | * @return $this |
||
207 | */ |
||
208 | public function setDefaultAssigneeAttribute($value) |
||
216 | |||
217 | /** |
||
218 | * Returns the aggregate value of number of issues in the project. |
||
219 | * |
||
220 | * @return int |
||
221 | */ |
||
222 | public function getIssuesCountAttribute() |
||
226 | |||
227 | /** |
||
228 | * Get total issues total quote time. |
||
229 | * |
||
230 | * @return int |
||
231 | */ |
||
232 | public function getTotalQuote() |
||
241 | |||
242 | /** |
||
243 | * Calculate the progress (open & closed issues). |
||
244 | * |
||
245 | * @return float|int |
||
246 | */ |
||
247 | public function getProgress() |
||
265 | |||
266 | /** |
||
267 | * Whether or not a user is member of the project. |
||
268 | * |
||
269 | * @param int $userId |
||
270 | * |
||
271 | * @return bool |
||
272 | */ |
||
273 | public function isMember($userId) |
||
277 | |||
278 | /** |
||
279 | * Whether or not the project is private. |
||
280 | * |
||
281 | * @return bool |
||
282 | */ |
||
283 | public function isPrivate() |
||
287 | |||
288 | /** |
||
289 | * Whether or not the project is public. |
||
290 | * |
||
291 | * @return bool |
||
292 | */ |
||
293 | public function isPublic() |
||
297 | |||
298 | /** |
||
299 | * Whether or not the project is private internal. |
||
300 | * |
||
301 | * @return bool |
||
302 | */ |
||
303 | public function isPrivateInternal() |
||
307 | |||
308 | /** |
||
309 | * Returns project status as string name. |
||
310 | * |
||
311 | * @return string |
||
312 | */ |
||
313 | public function getStatusAsName() |
||
321 | |||
322 | /** |
||
323 | * Returns the class name to be used for project status. |
||
324 | * |
||
325 | * @return string |
||
326 | */ |
||
327 | public function getStatusClass() |
||
335 | |||
336 | /** |
||
337 | * Get user preferred messaging type. |
||
338 | * |
||
339 | * @param int $userId |
||
340 | * |
||
341 | * @return mixed |
||
342 | */ |
||
343 | public function getPreferredMessageIdForUser($userId) |
||
350 | } |
||
351 |