Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why getFriends method returns all friends ? #144

Open
roshani3110 opened this issue Sep 21, 2020 · 4 comments
Open

Why getFriends method returns all friends ? #144

roshani3110 opened this issue Sep 21, 2020 · 4 comments

Comments

@roshani3110
Copy link

roshani3110 commented Sep 21, 2020

Hello,

Requirement :- to fetch friends of a specific group and I have used getFriends($perPage = 20, $group_name) method.

Problem :- getFriends($perPage = 20, $group_name) returns all friends of application and also getFriendsCount($group_name) returns count of all friends of application. can you please help me?

Here is code:

foreach ($groups as $group) { $group_name = $group->title; $group_connections = $user->getFriends($perPage = 20, $group_name); }

Thanks in advance!

@TechTailor
Copy link

Hey,

Can you share your group model & migration and the config/friendships.php file.

-TT

@roshani3110
Copy link
Author

config/friendships.php

`<?php

return [

'tables' => [
    'fr_pivot' => 'connections',
    'fr_groups_pivot' => 'user_connection_groups'
],

'groups' => [
    'acquaintances' => 0,
    'close_friends' => 1,
    'family' => 2
]

];`

Migration:-

`class CreateFriendshipsGroupsTable extends Migration
{

public function up() {

    Schema::create(config('friendships.tables.fr_groups_pivot'), function (Blueprint $table) {

        $table->integer('friendship_id')->unsigned();
        $table->morphs('friend');
        $table->integer('group_id')->unsigned();

        $table->foreign('friendship_id')
            ->references('id')
            ->on(config('friendships.tables.fr_pivot'))
            ->onDelete('cascade');

        $table->unique(['friendship_id', 'friend_id', 'friend_type', 'group_id'], 'unique');

    });

}

public function down() {
    Schema::dropIfExists(config('friendships.tables.fr_groups_pivot'));
}

}`

@TechTailor
Copy link

Does the group title you are retrieving from $group->title match the group names used in the config/friendship.php file?

-TT

@roshani3110
Copy link
Author

roshani3110 commented Sep 22, 2020

nope, also i tried this -> $user->getFriends($perPage = 20, 'family'); but didn't work. it returns empty array.

and one question - Does this package supports a 6.8 laravel version and 7.2 php version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants