title: laravel with relationship callback function and join it
body: <p>It's hard to explain what I need, but I will try.</p>
  
  <pre><code>$this-&gt;order-&gt;where("client_id", 5)
      -&gt;with([
          "roadOrderStatus" =&gt; function ($query) {
              $query-&gt;select("id", "identifier");
          },
          "currency"        =&gt; function ($query) {
              $query-&gt;join("translations", "currencies", '=', 'translations.id')
                  -&gt;join('translation_entries', 'translations.id', '=', 'translation_entries.translation_id')
                  -&gt;join('languages', 'translation_entries.language_id', '=', 'languages.id')
                  -&gt;whereIn('languages.code', ["eng"]);
          },
      ])-&gt;get();
  </code></pre>
  
  <p>I have two relationships on order (roadOrderStatus and currency). if in callbacks, I don't write anything, response is great. it works. but currency needs translation, because (currencies table has column called name and it's integer, because it gets translated). so if you look at my code, when fetching currency relationship , i also need to join to translations to get translated currency, but if I write joins in currency relationship callback like above, it returns - <code>currency - null</code></p>
  
  <p>I tried - </p>
  
  <pre><code>1) -&gt;whereIn('languages.code', ["eng"])-&gt;get();
  
  2) return $query-&gt;join("translations", .e.t.c)
  </code></pre>
  
  <p>My order model--</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Models\Orders;
  use App\Http\Traits\ScopeTrait;
  use Illuminate\Database\Eloquent\Model;
  
  class RoadOrder extends Model
  {
      use ScopeTrait;
  
      public function orderFinancialProperty(){
          return $this-&gt;morphOne("App\Http\Models\Orders\OrderFinancialProperty", "orderFinancialPropertable");
      }
  
      public function roadOrderStatus(){
          return $this-&gt;belongsTo("App\Http\Models\Orders\RoadOrderStatus");
      }
      public function roadTransportType(){
          return $this-&gt;belongsTo("App\Http\Models\Transport_Type\RoadTransportType");
      }
  
      public function currency(){
          return $this-&gt;belongsTo('App\Http\Models\Statics\Currency');
      }
  
      public function insurancer(){
          return $this-&gt;belongsTo("App\Http\Models\Insurance\Insurancer");
      }
  
  }
  </code></pre>