1 | <?php |
||
5 | class Snippet extends Model |
||
6 | { |
||
7 | /** |
||
8 | * A snippet may have multiple forks. |
||
9 | * |
||
10 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
11 | */ |
||
12 | public function forks() |
||
13 | { |
||
14 | return $this->hasMany(self::class, 'forked_id'); |
||
15 | } |
||
16 | |||
17 | /** |
||
18 | * A snippet may be forked from another snippet. |
||
19 | * |
||
20 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
21 | */ |
||
22 | public function originalSnippet() |
||
23 | { |
||
24 | return $this->belongsTo(self::class, 'forked_id'); |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * A snippet is owned by a user. |
||
29 | * |
||
30 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
31 | */ |
||
32 | public function user() |
||
33 | { |
||
34 | return $this->belongsTo(User::class); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Determine if the current snippet is a fork. |
||
39 | * |
||
40 | * @return bool |
||
41 | */ |
||
42 | public function isAFork() |
||
43 | { |
||
44 | return (bool) $this->forked_id; |
||
|
|||
45 | } |
||
46 | |||
47 | /** |
||
48 | * A snippet may have multiple votes. |
||
49 | * |
||
50 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
51 | */ |
||
52 | public function votes() |
||
56 | } |
||
57 |
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.