title: Error in laravel5.2: Method groups does not exist
body: <p>I am working on laravel 5.2.I want to display those members who belongs to that particular group which is open at this time. Actually, i am getting all the members which i have stored in my database but, i only want to access or display only those members who belongs to a particular on which i am currently accessing. I am getting an error: Method groups does not exist. which is shown below:<a href="https://i.stack.imgur.com/vN9mP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vN9mP.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/8PqON.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8PqON.png" alt="enter image description here"></a></p>
  
  <p>My controller:</p>
  
  <pre><code>     public function members($id){
       $dashes=Grouptable::findorFail($id);
       $members=Member::all();
       return view('members' , ['dashes'=&gt;$dashes,'members'=&gt;$members]);
  
       }
  
       public function dashboard($id){
       $dashes=Grouptable::findorFail($id);
       return view('dashboard' , ['dashes'=&gt;$dashes]);
  
       }
       public function addmembers(Request $request){
       $member=new Member();
       $member-&gt;members=$request['addmember'];
       $request-&gt;groups()-&gt;members()-&gt;save($member);
  
       return redirect()-&gt;back();
       }
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code>      &lt;body&gt;
       &lt;div class="row"&gt;
        &lt;div class="col-lg-3 col-lg-offset-1"&gt;
        &lt;img src="images/ImgResponsive_Placeholder.png" 
        class="img-circle img-  responsive" alt="Placeholder image"&gt; &lt;/div&gt;
       &lt;div class="col-lg-7"&gt;
       &lt;h1 style="color:black;"&gt;{{ $dashes-&gt;name }}&lt;/h1&gt;&lt;/div&gt;
          &lt;br /&gt;
       &lt;/div&gt;
        &lt;div class="row"&gt;
  
       &lt;div class="col-lg-3"&gt;
  
        &lt;button class="btn btn-success"  onclick="myFunction()"&gt;
         Add Members +   &lt;/button&gt;
         &lt;div&gt;
  
       &lt;form id="demo" style="display:none;" method="post"
        action="{{ route('addmember') }}"&gt;
       &lt;input class="form-control" type="text" name="addmember"&gt;
       &lt;button class="btn btn-primary" type="submit"&gt;Add&lt;/button&gt;
       &lt;input type="hidden" name="_token" value="{{ Session::token() }}"&gt;
       &lt;/form&gt;
  
           &lt;/div&gt;
            &lt;/div&gt;
  
          &lt;div class="col-lg-7 col-lg-offset-0"&gt;
         &lt;div class="panel panel-default"&gt;
         &lt;div  id="grp" class="panel-heading"&gt;
           &lt;h3 id="grouptitle" class="panel-title"&gt;Group Members&lt;/h3&gt;
         &lt;/div&gt;
           &lt;div  id="zx" class="panel-content"&gt;
           &lt;div class="row"&gt;
            @foreach($members as $member)
            &lt;section class="col-md-6"&gt;
  
            &lt;div class="row"&gt;
  
            &lt;section class="col-md-offset-1 col-md-3 col-xs-offset-1
             col-xs-4"&gt;
           &lt;img id="imagesize" src="images/g.jpg" class="img-circle"/&gt;
           &lt;/section&gt;
           &lt;section class="col-md-offset-1 col-md-7 col-xs-7"&gt;
            &lt;section class="col-md-12"&gt;
  
             &lt;h5 id="friendname"&gt;{{$member-&gt;members}}&lt;/h5&gt;
  
             &lt;/section&gt;
  
               &lt;/section&gt;
                &lt;/div&gt;
                &lt;/section&gt;
               &lt;/div&gt;
  
                &lt;/section&gt;
                @endforeach
  
           &lt;/div&gt;
            &lt;div id="mn" class="panel-footer"&gt;&lt;a id="seemr1"
            href="#.html"&gt;See More&lt;/a&gt;&lt;/div&gt;
             &lt;/div&gt;
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;/div&gt;
               &lt;/div&gt;
               &lt;/div&gt;
              &lt;/div&gt;
              &lt;/body&gt;
  </code></pre>
  
  <p>My routes:</p>
  
  <pre><code>             Route::get('/members/{id}',[
               'uses'=&gt;'GroupController@members',
               'as'=&gt;'members'
                ]);
                Route::get('/dashboard/{id}',[
                'uses'=&gt;'GroupController@dashboard',
               'as'=&gt;'dashboard'
                 ]);
                  Route::post('/member/add',[
                 'uses'=&gt;'GroupController@addmembers',
                 'as'=&gt;'addmember'
                 ]);
  </code></pre>
  
  <p>My modals:</p>
  
  <pre><code>                Grouptable:
                  public function members(){
                    return $this-&gt;hasMany('App\Member');
                   }
  
                 Member:
  
                    public function groups(){
                    return $this-&gt;hasMany('App\Grouptable');
                      }
  </code></pre>