title: Laravel Relationship Issues : Laravel 5.4
body: <p>I have 2 tables in my application... Users Conventioners</p>
  
  <p>I have users id in the conventioners table and i want to access their genders from the Users table....</p>
  
  <p>I have like 10 user ids in the conventioners table and 20 users in the users table...</p>
  
  <p>Please how do I access all their genders in the users table...</p>
  
  <pre><code>$conventioners-&gt;users()-&gt;gender
  </code></pre>
  
  <p>Conventioners is an instance of the Conventioner Model which contains a relationship **belongsToMany</p>
  
  <p>Thanks alot guys</p>
  
  <p>Here is my Conventioner Model</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Conventioner extends Model
  {
      /**
       * @var string
       */
      protected $table = 'conventioners';
  
      /**
       * @var array
       */
      protected $fillable = [
          'user_id','year','church_id','convention_id'
      ];
  
      /**
       * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
       */
      public function user()
      {
          return $this-&gt;belongsTo('App\User');
      }
  
      /**
       * @return \Illuminate\Database\Eloquent\Relations\HasMany
       */
      public function users()
      {
          return $this-&gt;hasMany('App\User');
      }
  
      /**
       * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
       */
      public function convention()
      {
          return $this-&gt;belongsTo('App\Convention');
      }
  }
  </code></pre>
  
  <p>Here is my ConventionController method called Convention...
  It retrieves the details for the current convention</p>
  
  <pre><code>public function convention($slug)
      {
          if(!$this-&gt;admin()) return redirect()-&gt;back();
  
          $convention = Convention::where('slug', $slug)-&gt;first();
  
          $participants = Conventioner::where('convention_id', $convention-&gt;id)-&gt;get();
  
          $conventioner = [];
          foreach($participants as $participant)
          {
              $thisUser = [];
              $thisUser['data'] = User::withTrashed()-&gt;where('id', $participant-&gt;user_id)-&gt;first();
              $thisUser['convention'] = $participant;
              array_push($conventioner, $thisUser);
          }
  
          var_dump($participants-&gt;users()-&gt;pluck('gender')-&gt;all());
  
          return view('dashboard/conventions/convention', [
              'convention' =&gt; $convention,
              'user' =&gt; Auth::user(),
              'conventioners' =&gt; $convention-&gt;conventioners(),
              'participants' =&gt; $conventioner
          ]);
      }
  </code></pre>