Hootlex\Friendships\Traits\Friendable::blockFriend PHP Method

blockFriend() public method

public blockFriend ( Model $recipient ) : Friendship
$recipient Illuminate\Database\Eloquent\Model
return Hootlex\Friendships\Models\Friendship
    public function blockFriend(Model $recipient)
    {
        // if there is a friendship between the two users and the sender is not blocked
        // by the recipient user then delete the friendship
        if (!$this->isBlockedBy($recipient)) {
            $this->findFriendship($recipient)->delete();
        }
        $friendship = (new Friendship())->fillRecipient($recipient)->fill(['status' => Status::BLOCKED]);
        Event::fire('friendships.blocked', [$this, $recipient]);
        return $this->friends()->save($friendship);
    }