1 | <?php |
||
31 | class Project extends Model |
||
32 | { |
||
33 | use Traits\CountAttributeTrait, |
||
34 | Traits\Project\CountTrait, |
||
35 | Traits\Project\FilterTrait, |
||
36 | Traits\Project\SortTrait, |
||
37 | Traits\Project\RelationTrait, |
||
38 | Traits\Project\CrudTrait, |
||
39 | Traits\Project\QueryTrait; |
||
40 | |||
41 | /** |
||
42 | * Project private & user role can see their own issues only. |
||
43 | * |
||
44 | * @var int |
||
45 | */ |
||
46 | const INTERNAL_YES = 2; |
||
47 | |||
48 | /** |
||
49 | * Project not public to view and create issue. |
||
50 | * |
||
51 | * @var int |
||
52 | */ |
||
53 | const PRIVATE_YES = 1; |
||
54 | |||
55 | /** |
||
56 | * Project public to view and create issue. |
||
57 | * |
||
58 | * @var int |
||
59 | */ |
||
60 | const PRIVATE_NO = 0; |
||
61 | |||
62 | /** |
||
63 | * All projects. |
||
64 | * |
||
65 | * @var int |
||
66 | */ |
||
67 | const PRIVATE_ALL = -1; |
||
68 | |||
69 | /** |
||
70 | * Project status Open. |
||
71 | * |
||
72 | * @var int |
||
73 | */ |
||
74 | const STATUS_OPEN = 1; |
||
75 | |||
76 | /** |
||
77 | * Project status Archived. |
||
78 | * |
||
79 | * @var int |
||
80 | */ |
||
81 | const STATUS_ARCHIVED = 0; |
||
82 | |||
83 | /** |
||
84 | * Timestamp enabled. |
||
85 | * |
||
86 | * @var bool |
||
87 | */ |
||
88 | public $timestamps = true; |
||
89 | |||
90 | /** |
||
91 | * Name of database table. |
||
92 | * |
||
93 | * @var string |
||
94 | */ |
||
95 | protected $table = 'projects'; |
||
96 | |||
97 | /** |
||
98 | * List of allowed columns to be used in $this->fill(). |
||
99 | * |
||
100 | * @var array |
||
101 | */ |
||
102 | protected $fillable = ['name', 'default_assignee', 'status', 'private']; |
||
103 | 43 | ||
104 | /** |
||
105 | 43 | * List of HTML classes for each status. |
|
106 | * |
||
107 | * @var array |
||
108 | */ |
||
109 | protected $attrClassNames = [ |
||
110 | self::PRIVATE_NO => 'note', |
||
111 | self::PRIVATE_YES => 'info', |
||
112 | self::INTERNAL_YES => 'primary', |
||
113 | 5 | ]; |
|
114 | |||
115 | 5 | /** |
|
116 | * List of statuses names. |
||
117 | * |
||
118 | * @var array |
||
119 | */ |
||
120 | protected $statusesNames = [ |
||
121 | self::PRIVATE_NO => 'public', |
||
122 | self::PRIVATE_YES => 'private', |
||
123 | 1 | self::INTERNAL_YES => 'internal', |
|
124 | ]; |
||
125 | 1 | ||
126 | /** |
||
127 | * Generate a URL for the active project. |
||
128 | * |
||
129 | * @param string $url |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | public function to($url = '') |
||
137 | 49 | ||
138 | 31 | /** |
|
139 | * Returns the aggregate value of number of open issues in the project. |
||
140 | * |
||
141 | 49 | * @return int |
|
142 | */ |
||
143 | public function getOpenIssuesCountAttribute() |
||
147 | |||
148 | /** |
||
149 | * Returns the aggregate value of number of closed issues in the project. |
||
150 | * |
||
151 | * @return int |
||
152 | */ |
||
153 | public function getClosedIssuesCountAttribute() |
||
157 | |||
158 | /** |
||
159 | 3 | * Set default assignee attribute. |
|
160 | * |
||
161 | 3 | * @param int $value |
|
162 | 3 | * |
|
163 | 3 | * @return $this |
|
164 | */ |
||
165 | public function setDefaultAssigneeAttribute($value) |
||
173 | |||
174 | 1 | /** |
|
175 | * Returns the aggregate value of number of issues in the project. |
||
176 | 1 | * |
|
177 | 1 | * @return int |
|
178 | 1 | */ |
|
179 | 1 | public function getIssuesCountAttribute() |
|
183 | 1 | ||
184 | 1 | /** |
|
185 | 1 | * Get total issues total quote time. |
|
186 | 1 | * |
|
187 | * @return int |
||
188 | */ |
||
189 | public function getTotalQuote() |
||
198 | |||
199 | /** |
||
200 | 8 | * Calculate the progress (open & closed issues). |
|
201 | * |
||
202 | 8 | * @return float|int |
|
203 | */ |
||
204 | public function getProgress() |
||
222 | |||
223 | /** |
||
224 | * Whether or not a user is member of the project. |
||
225 | * |
||
226 | * @param int $userId |
||
227 | * |
||
228 | * @return bool |
||
229 | */ |
||
230 | public function isMember($userId) |
||
234 | |||
235 | /** |
||
236 | * Whether or not the project is private or public. |
||
237 | * |
||
238 | * @return bool |
||
239 | */ |
||
240 | public function isPrivate() |
||
244 | |||
245 | /** |
||
246 | * Whether or not the project is private internal. |
||
247 | * |
||
248 | * @return bool |
||
249 | */ |
||
250 | public function isPrivateInternal() |
||
254 | |||
255 | /** |
||
256 | * Returns project status as string name. |
||
257 | * |
||
258 | * @return string |
||
259 | */ |
||
260 | public function getStatusAsName() |
||
268 | |||
269 | /** |
||
270 | * Returns the class name to be used for project status. |
||
271 | * |
||
272 | * @return string |
||
273 | */ |
||
274 | public function getStatusClass() |
||
282 | } |
||
283 |