From 9fe22178cd0b64fdd6b03c50cd4c31a524792484 Mon Sep 17 00:00:00 2001 From: Amr Date: Tue, 9 May 2017 04:46:59 +0200 Subject: [PATCH] Fix code style --- src/Friendable.php | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/Friendable.php b/src/Friendable.php index 9345ccf..f5641a3 100644 --- a/src/Friendable.php +++ b/src/Friendable.php @@ -11,7 +11,6 @@ public function addFriend($recipient) $friendshipStatus = $this->checkFriendship($recipient); if ($friendshipStatus == 'not friends') { - Event::fire('friendrequest.sent', [$this, $recipient]); return Friendship::create([ @@ -19,8 +18,6 @@ public function addFriend($recipient) 'user_requested' => $recipient->id, ]); } - - return 0; } public function checkFriendship($user) @@ -34,11 +31,15 @@ public function checkFriendship($user) if (!$friendship) { return 'not friends'; - } elseif ($friendship->status == 1) { + } + + if ($friendship->status == 1) { return 'friends'; - } elseif ($friendship->requester == $this->id) { + } + if ($friendship->requester == $this->id) { return 'waiting'; - } elseif ($friendship->user_requested == $this->id) { + } + if ($friendship->user_requested == $this->id) { return 'pending'; } } @@ -66,25 +67,40 @@ public function deleteFriend($user) public function friends() { - $recipients = Friendship::whereSender($this)->accepted(1)->pluck('user_requested')->all(); - $senders = Friendship::whereRecipient($this)->accepted(1)->pluck('requester')->all(); + $recipients = Friendship::whereSender($this) + ->accepted(1) + ->pluck('user_requested') + ->all(); + $senders = Friendship::whereRecipient($this) + ->accepted(1) + ->pluck('requester') + ->all(); $friendsIds = array_merge($recipients, $senders); - return static::whereIn('id', $friendsIds)->get(); + return static::whereIn('id', $friendsIds) + ->get(); } public function friendRequestFrom() { - $senders = Friendship::whereRecipient($this)->accepted(0)->pluck('requester')->all(); + $senders = Friendship::whereRecipient($this) + ->accepted(0) + ->pluck('requester') + ->all(); - return static::whereIn('id', $senders)->get(); + return static::whereIn('id', $senders) + ->get(); } public function friendRequestTo() { - $recipients = Friendship::whereSender($this)->accepted(0)->pluck('user_requested')->all(); + $recipients = Friendship::whereSender($this) + ->accepted(0) + ->pluck('user_requested') + ->all(); - return static::whereIn('id', $recipients)->get(); + return static::whereIn('id', $recipients) + ->get(); } }