1 | <?php |
||
14 | trait CanBeFollowed |
||
15 | { |
||
16 | /** |
||
17 | * Check if entity is followed by given entity. |
||
18 | * |
||
19 | * @param int|\Illuminate\Database\Eloquent\Model $follower |
||
20 | * |
||
21 | * @return bool |
||
22 | */ |
||
23 | public function isFollowedBy($follower) |
||
24 | { |
||
25 | return $this->followers->contains($follower); |
||
|
|||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Returns the entity that followed this entity. |
||
30 | * |
||
31 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
32 | */ |
||
33 | 1 | public function followers() |
|
37 | } |
||
38 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: