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 | 'slug' => '', |
||
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 | 'slug' => '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 | 'status', |
||
62 | 'tags', |
||
63 | 'slug', |
||
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 | 'status' => 'int|required', |
||
77 | 'slug' => 'required|string', |
||
78 | ]; |
||
79 | |||
80 | /** |
||
81 | * Projects can belong to a team. |
||
82 | * |
||
83 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
84 | */ |
||
85 | public function group() |
||
86 | { |
||
87 | return $this->belongsTo(Group::class, 'namespace_id', 'id'); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * Lookup all of the issues reported on the project. |
||
92 | * |
||
93 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
94 | */ |
||
95 | public function issues() |
||
99 | |||
100 | /** |
||
101 | * Projects can have many tags. |
||
102 | * |
||
103 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
104 | */ |
||
105 | public function tags() |
||
109 | |||
110 | /** |
||
111 | * Finds all projects by status. |
||
112 | * |
||
113 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
114 | * @param int $status |
||
115 | * |
||
116 | * @return \Illuminate\Database\Eloquent\Builder |
||
117 | */ |
||
118 | public function scopeStatus(Builder $query, $status) |
||
122 | |||
123 | /** |
||
124 | * Finds all projects which don't have the given status. |
||
125 | * |
||
126 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
127 | * @param int $status |
||
128 | * |
||
129 | * @return \Illuminate\Database\Eloquent\Builder |
||
130 | */ |
||
131 | public function scopeNotStatus(Builder $query, $status) |
||
135 | |||
136 | /** |
||
137 | * Finds all projects which are enabled. |
||
138 | * |
||
139 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
140 | * |
||
141 | * @return \Illuminate\Database\Eloquent\Builder |
||
142 | */ |
||
143 | public function scopeEnabled(Builder $query) |
||
147 | |||
148 | /** |
||
149 | * Finds all projects which are disabled. |
||
150 | * |
||
151 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
152 | * |
||
153 | * @return \Illuminate\Database\Eloquent\Builder |
||
154 | */ |
||
155 | public function scopeDisabled(Builder $query) |
||
159 | |||
160 | /** |
||
161 | * Looks up the human readable version of the status. |
||
162 | * |
||
163 | * @return string |
||
164 | */ |
||
165 | public function getHumanStatusAttribute() |
||
169 | |||
170 | /** |
||
171 | * Returns all of the tags on this project. |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | public function getTagsListAttribute() |
||
183 | |||
184 | /** |
||
185 | * Get the presenter class. |
||
186 | * |
||
187 | * @return string |
||
188 | */ |
||
189 | public function getPresenterClass() |
||
193 | } |
||
194 |
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.