title: Select columns from pivot table in BelongsToMany Relationship
body: <p>I have this query that works perfectly but I would like it to select only the id and title of the post.</p>
  <pre><code>$posts = $this-&gt;section1-&gt;posts()
                  -&gt;with([
                      'survey' =&gt; function ($query) {
                          $query-&gt;withCount('totalSurveys');
                      },
                      'survey.surveyOptions',
                      'survey.totalSurveys.survey_option.color',
                      'image',
                      'categories:id,name,slug',
                  ])
                  -&gt;withCount('comments')
                  -&gt;where('status', Post::PUBLICADO)
                  -&gt;orderBy('order', 'ASC')
                  ​-&gt;get();
  </code></pre>
  <p><strong>section model</strong></p>
  <pre><code>class Section extends Model
  {
      use HasFactory;
      protected $guarded = ['id'];
      public function posts()
      {
          return $this-&gt;belongsToMany(Post::class);
      }
  }
  </code></pre>
  <p>I tried selecting the fields through the relationship but it didn't work:</p>
  <pre><code>public function posts()
          {
              return $this-&gt;belongsToMany(Post::class)-&gt;select(['id', 'title']);
          }
  </code></pre>
  <p>Can anyone help me ? thank you</p>