1 | <?php |
||
54 | class Project extends Model implements HasPresenter |
||
55 | { |
||
56 | use SoftDeletes, ValidatingTrait, HasVisibilities; |
||
57 | |||
58 | /** |
||
59 | * List of attributes that have default values. |
||
60 | * |
||
61 | * @var mixed[] |
||
62 | */ |
||
63 | protected $attributes = [ |
||
64 | 'owner_id' => 0, |
||
65 | 'description' => '', |
||
66 | 'path' => '', |
||
67 | 'creator_id' => 0, |
||
68 | ]; |
||
69 | |||
70 | /** |
||
71 | * The attributes that should be casted to native types. |
||
72 | * |
||
73 | * @var string[] |
||
74 | */ |
||
75 | protected $casts = [ |
||
76 | 'id' => 'int', |
||
77 | 'owner_id' => 'int', |
||
78 | 'description' => 'string', |
||
79 | 'path' => 'string', |
||
80 | 'issues_enabled' => 'boolean', |
||
81 | 'creator_id' => 'int', |
||
82 | 'deleted_at' => 'date', |
||
83 | ]; |
||
84 | |||
85 | /** |
||
86 | * The fillable properties. |
||
87 | * |
||
88 | * @var string[] |
||
89 | */ |
||
90 | protected $fillable = [ |
||
91 | 'name', |
||
92 | 'description', |
||
93 | 'visibility_level', |
||
94 | 'tags', |
||
95 | 'path', |
||
96 | 'issues_enabled', |
||
97 | 'creator_id', |
||
98 | 'owner_id', |
||
99 | ]; |
||
100 | |||
101 | /** |
||
102 | * The validation rules. |
||
103 | * |
||
104 | * @var string[] |
||
105 | */ |
||
106 | public $rules = [ |
||
107 | 'name' => 'required|string', |
||
108 | 'visibility_level' => 'int|required', |
||
109 | 'path' => 'required|string|max:15', |
||
110 | ]; |
||
111 | |||
112 | /** |
||
113 | * Projects can belong to a group. |
||
114 | * |
||
115 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
116 | */ |
||
117 | public function owner() |
||
121 | |||
122 | /** |
||
123 | * Projects can belong to a creator. |
||
124 | * |
||
125 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
126 | */ |
||
127 | public function creator() |
||
131 | |||
132 | /** |
||
133 | * Lookup all of the issues reported on the project. |
||
134 | * |
||
135 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
136 | */ |
||
137 | public function issues() |
||
141 | |||
142 | /** |
||
143 | * Projects can have many tags. |
||
144 | * |
||
145 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
146 | */ |
||
147 | public function tags() |
||
151 | |||
152 | /** |
||
153 | * Find by owner_path & project_path, or throw an exception. |
||
154 | * |
||
155 | * @param string $owner_path |
||
156 | * @param string $project_path |
||
157 | * @param string[] $columns |
||
158 | * |
||
159 | * @throws \Illuminate\Database\Eloquent\ModelNotFoundException |
||
160 | * |
||
161 | * @return \Gitamin\Models\User |
||
162 | */ |
||
163 | public static function findByPath($owner_path, $project_path, $columns = ['*']) |
||
177 | |||
178 | /** |
||
179 | * Finds all projects by visibility_level. |
||
180 | * |
||
181 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
182 | * @param int $visibility_level |
||
183 | * |
||
184 | * @return \Illuminate\Database\Eloquent\Builder |
||
185 | */ |
||
186 | public function scopeVisibilityLevel(Builder $query, $visibility_level) |
||
190 | |||
191 | /** |
||
192 | * Finds all projects which don't have the given visibility_level. |
||
193 | * |
||
194 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
195 | * @param int $visibility_level |
||
196 | * |
||
197 | * @return \Illuminate\Database\Eloquent\Builder |
||
198 | */ |
||
199 | public function scopeNotVisibilityLevel(Builder $query, $visibility_level) |
||
203 | |||
204 | /** |
||
205 | * Looks up the human readable version of the visibility_level. |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | public function getHumanVisibilityLevelAttribute() |
||
213 | |||
214 | /** |
||
215 | * Returns project route. |
||
216 | * |
||
217 | * @return string |
||
218 | */ |
||
219 | public function getUrlAttribute() |
||
223 | |||
224 | /** |
||
225 | * Returns project owner path. |
||
226 | * |
||
227 | * @return string |
||
228 | */ |
||
229 | public function getOwnerPathAttribute() |
||
233 | |||
234 | /** |
||
235 | * Returns all of the tags on this project. |
||
236 | * |
||
237 | * @return string |
||
238 | */ |
||
239 | public function getTagsListAttribute() |
||
247 | |||
248 | /** |
||
249 | * Get the presenter class. |
||
250 | * |
||
251 | * @return string |
||
252 | */ |
||
253 | public function getPresenterClass() |
||
257 | } |
||
258 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.