1 | <?php |
||
21 | class Project extends Model implements HasPresenter |
||
22 | { |
||
23 | use SoftDeletes, ValidatingTrait; |
||
24 | |||
25 | /** |
||
26 | * List of attributes that have default values. |
||
27 | * |
||
28 | * @var mixed[] |
||
29 | */ |
||
30 | protected $attributes = [ |
||
31 | 'order' => 0, |
||
32 | 'namespace_id' => 0, |
||
33 | 'description' => '', |
||
34 | 'path' => '', |
||
35 | 'enabled' => true, |
||
36 | ]; |
||
37 | |||
38 | /** |
||
39 | * The attributes that should be casted to native types. |
||
40 | * |
||
41 | * @var string[] |
||
42 | */ |
||
43 | protected $casts = [ |
||
44 | 'id' => 'int', |
||
45 | 'order' => 'int', |
||
46 | 'namespace_id' => 'int', |
||
47 | 'description' => 'string', |
||
48 | 'path' => 'string', |
||
49 | 'deleted_at' => 'date', |
||
50 | 'enabled' => 'bool', |
||
51 | ]; |
||
52 | |||
53 | /** |
||
54 | * The fillable properties. |
||
55 | * |
||
56 | * @var string[] |
||
57 | */ |
||
58 | protected $fillable = [ |
||
59 | 'name', |
||
60 | 'description', |
||
61 | 'visibility_level', |
||
62 | 'tags', |
||
63 | 'path', |
||
64 | 'order', |
||
65 | 'namespace_id', |
||
66 | 'enabled', |
||
67 | ]; |
||
68 | |||
69 | /** |
||
70 | * The validation rules. |
||
71 | * |
||
72 | * @var string[] |
||
73 | */ |
||
74 | public $rules = [ |
||
75 | 'name' => 'required|string', |
||
76 | 'visibility_level' => 'int|required', |
||
77 | 'path' => 'required|string|max:5', |
||
78 | ]; |
||
79 | |||
80 | /** |
||
81 | * Projects can belong to a group. |
||
82 | * |
||
83 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
84 | */ |
||
85 | public function group() |
||
89 | |||
90 | /** |
||
91 | * Projects can belong to a namespace. |
||
92 | * |
||
93 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
94 | */ |
||
95 | public function projectNamespace() |
||
99 | |||
100 | /** |
||
101 | * Lookup all of the issues reported on the project. |
||
102 | * |
||
103 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
104 | */ |
||
105 | public function issues() |
||
109 | |||
110 | /** |
||
111 | * Projects can have many tags. |
||
112 | * |
||
113 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
114 | */ |
||
115 | public function tags() |
||
119 | |||
120 | /** |
||
121 | * Finds all projects by visibility_level. |
||
122 | * |
||
123 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
124 | * @param int $visibility_level |
||
125 | * |
||
126 | * @return \Illuminate\Database\Eloquent\Builder |
||
127 | */ |
||
128 | public function scopeVisibilityLevel(Builder $query, $visibility_level) |
||
132 | |||
133 | /** |
||
134 | * Finds all projects which don't have the given visibility_level. |
||
135 | * |
||
136 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
137 | * @param int $visibility_level |
||
138 | * |
||
139 | * @return \Illuminate\Database\Eloquent\Builder |
||
140 | */ |
||
141 | public function scopeNotVisibilityLevel(Builder $query, $visibility_level) |
||
145 | |||
146 | /** |
||
147 | * Finds all projects which are enabled. |
||
148 | * |
||
149 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
150 | * |
||
151 | * @return \Illuminate\Database\Eloquent\Builder |
||
152 | */ |
||
153 | public function scopeEnabled(Builder $query) |
||
157 | |||
158 | /** |
||
159 | * Finds all projects which are disabled. |
||
160 | * |
||
161 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
162 | * |
||
163 | * @return \Illuminate\Database\Eloquent\Builder |
||
164 | */ |
||
165 | public function scopeDisabled(Builder $query) |
||
169 | |||
170 | /** |
||
171 | * Looks up the human readable version of the visibility_level. |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | public function getHumanVisibilityLevelAttribute() |
||
179 | |||
180 | /** |
||
181 | * Returns the namespace on this project. |
||
182 | * |
||
183 | * @return string |
||
184 | */ |
||
185 | public function getNamespaceAttribute() |
||
189 | |||
190 | /** |
||
191 | * Returns all of the tags on this project. |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | public function getTagsListAttribute() |
||
203 | |||
204 | /** |
||
205 | * Get the presenter class. |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | public function getPresenterClass() |
||
213 | } |
||
214 |
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.