3 months ago

how to show records only which have at least one relationship

Posted 3 months ago by mostafalaravel


I would like to show all users having at least one group.

group and user are manyToMany relationship,

Because the request bellow shows also users with 0 group count() :

    public function index()
        $user = User::all();
        return response()->view('admin.member', ['members' => $user], 200);

in view:

                                {{ $member->groups->count() }}


Please sign in or create an account to participate in this conversation.