| @@ 95-107 (lines=13) @@ | ||
| 92 | /** |
|
| 93 | * @return \Illuminate\Database\Eloquent\Collection |
|
| 94 | */ |
|
| 95 | public function incoming_friends() |
|
| 96 | { |
|
| 97 | $me = $this->with([ |
|
| 98 | 'friends_i_am_recipient' => function ($query) { |
|
| 99 | $query->where('status', Status::PENDING) |
|
| 100 | ->get(); |
|
| 101 | }, |
|
| 102 | ]) |
|
| 103 | ->where('id', '=', $this->getKey()) |
|
| 104 | ->first(); |
|
| 105 | ||
| 106 | return $me->friends_i_am_recipient; |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * @return \Illuminate\Database\Eloquent\Collection |
|
| @@ 112-124 (lines=13) @@ | ||
| 109 | /** |
|
| 110 | * @return \Illuminate\Database\Eloquent\Collection |
|
| 111 | */ |
|
| 112 | public function any_friends() |
|
| 113 | { |
|
| 114 | $me = $this->with([ |
|
| 115 | 'friends_i_am_sender', |
|
| 116 | 'friends_i_am_recipient', |
|
| 117 | ]) |
|
| 118 | ->where('id', '=', $this->getKey()) |
|
| 119 | ->first(); |
|
| 120 | ||
| 121 | $any_friends = $this->mergedFriends($me); |
|
| 122 | ||
| 123 | return $any_friends; |
|
| 124 | } |
|
| 125 | ||
| 126 | /** |
|
| 127 | * Alias to eloquent many-to-many relation's attach() method. |
|