@@ -231,7 +231,7 @@ |
||
| 231 | 231 | /** |
| 232 | 232 | * Get the number of friends |
| 233 | 233 | * |
| 234 | - * @return \Illuminate\Database\Eloquent\Collection |
|
| 234 | + * @return integer |
|
| 235 | 235 | */ |
| 236 | 236 | public function getFriendsCount() |
| 237 | 237 | { |
@@ -313,13 +313,13 @@ |
||
| 313 | 313 | |
| 314 | 314 | |
| 315 | 315 | $fofs = Friendship::where('status', Status::ACCEPTED) |
| 316 | - ->where(function ($query) use ($friendIds) { |
|
| 317 | - $query->where(function ($q) use ($friendIds) { |
|
| 318 | - $q->whereIn('sender_id', $friendIds); |
|
| 319 | - })->orWhere(function ($q) use ($friendIds) { |
|
| 320 | - $q->whereIn('recipient_id', $friendIds); |
|
| 321 | - }); |
|
| 322 | - })->get(['sender_id', 'recipient_id']); |
|
| 316 | + ->where(function ($query) use ($friendIds) { |
|
| 317 | + $query->where(function ($q) use ($friendIds) { |
|
| 318 | + $q->whereIn('sender_id', $friendIds); |
|
| 319 | + })->orWhere(function ($q) use ($friendIds) { |
|
| 320 | + $q->whereIn('recipient_id', $friendIds); |
|
| 321 | + }); |
|
| 322 | + })->get(['sender_id', 'recipient_id']); |
|
| 323 | 323 | |
| 324 | 324 | $fofIds = array_unique( |
| 325 | 325 | array_merge($fofs->pluck('sender_id')->all(), $fofs->lists('recipient_id')->all()) |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function befriend(Model $recipient) |
| 17 | 17 | { |
| 18 | - if (! $this->canBefriend($recipient)) { |
|
| 18 | + if (!$this->canBefriend($recipient)) { |
|
| 19 | 19 | return false; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | //If sender has a friendship with the recipient return false |
| 244 | 244 | if ($friendship = $this->getFriendship($recipient)) { |
| 245 | 245 | //if previous friendship was Denied then let the user send fr |
| 246 | - if (! $friendship->status == Status::DENIED) { |
|
| 246 | + if (!$friendship->status == Status::DENIED) { |
|
| 247 | 247 | return false; |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -269,10 +269,10 @@ discard block |
||
| 269 | 269 | private function findFriendships($status = '%') |
| 270 | 270 | { |
| 271 | 271 | return Friendship::where('status', 'LIKE', $status) |
| 272 | - ->where(function ($query) { |
|
| 273 | - $query->where(function ($q) { |
|
| 272 | + ->where(function($query) { |
|
| 273 | + $query->where(function($q) { |
|
| 274 | 274 | $q->whereSender($this); |
| 275 | - })->orWhere(function ($q) { |
|
| 275 | + })->orWhere(function($q) { |
|
| 276 | 276 | $q->whereRecipient($this); |
| 277 | 277 | }); |
| 278 | 278 | }); |
@@ -306,10 +306,10 @@ discard block |
||
| 306 | 306 | $friendIds = array_unique(array_merge($recipients, $senders)); |
| 307 | 307 | |
| 308 | 308 | $fofs = Friendship::where('status', Status::ACCEPTED) |
| 309 | - ->where(function ($query) use ($friendIds) { |
|
| 310 | - $query->where(function ($q) use ($friendIds) { |
|
| 309 | + ->where(function($query) use ($friendIds) { |
|
| 310 | + $query->where(function($q) use ($friendIds) { |
|
| 311 | 311 | $q->whereIn('sender_id', $friendIds); |
| 312 | - })->orWhere(function ($q) use ($friendIds) { |
|
| 312 | + })->orWhere(function($q) use ($friendIds) { |
|
| 313 | 313 | $q->whereIn('recipient_id', $friendIds); |
| 314 | 314 | }); |
| 315 | 315 | })->get(['sender_id', 'recipient_id']); |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | { |
| 8 | 8 | public function up() |
| 9 | 9 | { |
| 10 | - Schema::create('friendships', function (Blueprint $table) { |
|
| 10 | + Schema::create('friendships', function(Blueprint $table) { |
|
| 11 | 11 | $table->increments('id'); |
| 12 | 12 | $table->morphs('sender'); |
| 13 | 13 | $table->morphs('recipient'); |
@@ -75,10 +75,10 @@ |
||
| 75 | 75 | */ |
| 76 | 76 | public function scopeBetweenModels($query, $sender, $recipient) |
| 77 | 77 | { |
| 78 | - $query->where(function ($queryIn) use ($sender, $recipient) { |
|
| 79 | - $queryIn->where(function ($q) use ($sender, $recipient) { |
|
| 78 | + $query->where(function($queryIn) use ($sender, $recipient) { |
|
| 79 | + $queryIn->where(function($q) use ($sender, $recipient) { |
|
| 80 | 80 | $q->whereSender($sender)->whereRecipient($recipient); |
| 81 | - })->orWhere(function ($q) use ($sender, $recipient) { |
|
| 81 | + })->orWhere(function($q) use ($sender, $recipient) { |
|
| 82 | 82 | $q->whereSender($recipient)->whereRecipient($sender); |
| 83 | 83 | }); |
| 84 | 84 | }); |