title: Yii2 dataprovider with manytomany relation
body: <p>I try to build a grid view with many-to-many relations. So I need a query for the <code>ActiveDataProvider</code> . </p>
  
  <p>I have a table 'ressource', a table 'type' and between them a table 'historique'.</p>
  
  <p>I have the good relation in my models but I don't know how to create the dataProvider. </p>
  
  <p>In my model Ressource : </p>
  
  <pre><code>public function getHistorique()
  {
      return $this-&gt;hasMany(Historique::className(), ['idType' =&gt; 'idType']);
  }
  
  
  
  public function getType()
  {
       return $this-&gt;hasMany(Type::className(), ['idType' =&gt; 'idType'])
          -&gt;viaTable(Historique::className(), ['idRessource' =&gt; 'idRessource']);   
  }
  </code></pre>
  
  <p>In my model Historique :</p>
  
  <pre><code>public function getType()
  {
      return $this-&gt;hasOne(Type::className(), ['idType' =&gt; 'idType']);
  }
  
  public function getRessource()
  {
      return $this-&gt;hasOne(Ressource::className(), ['idRessource' =&gt; 'idRessource']);
  }
  </code></pre>
  
  <p>and finally in my model Type :</p>
  
  <pre><code>public function getHistorique()
  {
      return $this-&gt;hasMany(Historique::className(), ['idType' =&gt; 'idType']);
  }
  public function getRessource()
  {
      return $this-&gt;hasMany(Ressource::className(), ['idRessource' =&gt; 'idRessource'])
          -&gt;viaTable(Historique::className(), ['idType' =&gt; 'idType']);
  }
  </code></pre>
  
  <p>So in the Controller (in fact my ModelSearch), I want to have ressources with type from the table historique. I don't know what I have to add after</p>
  
  <pre><code>Ressource::find();
  </code></pre>