Hootlex\Friendships\Models\Friendship::scopeBetweenModels PHP Method

scopeBetweenModels() public method

public scopeBetweenModels ( $query, Model $sender, Model $recipient ) : Builder
$query
$sender Illuminate\Database\Eloquent\Model
$recipient Illuminate\Database\Eloquent\Model
return Illuminate\Database\Eloquent\Builder
    public function scopeBetweenModels($query, $sender, $recipient)
    {
        $query->where(function ($queryIn) use($sender, $recipient) {
            $queryIn->where(function ($q) use($sender, $recipient) {
                $q->whereSender($sender)->whereRecipient($recipient);
            })->orWhere(function ($q) use($sender, $recipient) {
                $q->whereSender($recipient)->whereRecipient($sender);
            });
        });
    }