title: Laravel eloquent: Multiply two columns of two different tables
body: <h2>My Order Model</h2>
  
  <pre><code>class Order extends Model
  {
      protected $fillable = [
          'id','user_id', 'erp_id', 'currency_code','ex_rate_with_base','order_status','status','created_at'
      ];
  
      protected $hidden = ['updated_at',];
  
      public function orderList(){
          return $this-&gt;hasMany(OrderList::class);
      }   
  
      public function currency(){
          return $this-&gt;belongsTo(Currency::class,'currency_code');
      }
  
  }
  </code></pre>
  
  <h2>My Currency Model</h2>
  
  <pre><code>class Currency extends Model
  {
  
      protected $fillable = [
          'currency_code','currency_name', 'currency_symbol', 'ex_rate_with_base', 'update_via', 'status',
      ];
      protected $hidden = [
          'created_at','updated_at','updated_by','created_by',
      ];
  
      protected $primaryKey = 'currency_code';
  
      public $incrementing = false;
  
      public function order()
      {
          return $this-&gt;hasMany(Order::class,'currency_code');
      }
  }
  </code></pre>
  
  <h2>My OrderList Model</h2>
  
  <pre><code>class OrderList extends Model
  {
      protected $fillable = [
          'id','order_id', 'product_code', 'qty','unit_price','status',
      ];
  
      protected $hidden = [
         'created_at' ,'updated_at',
      ];
  
      public function order(){
          return $this-&gt;belongsTo(Order::class);
      }
  }
  </code></pre>
  
  <hr>
  
  <p>In my Order controller I want to run the query:</p>
  
  <pre><code>$order_history_list = Order::where([['user_id', $user-&gt;id], ['updated_at','&gt;', $updated_at]])
      -&gt;with([
          'currency' =&gt; function ($query) {
              $query-&gt;select('currency_code','currency_symbol','ex_rate_with_base');
          },
          'orderList' =&gt; function ($query) {
              $query-&gt;select('id','order_id', 'product_code', '***order_lists.qty * orders.ex_rate_with_base AS unit_price_with_ex_rate***','status');
          }
      ])-&gt;get();
  </code></pre>
  
  <p>But error is occuring due to the highlighted portion.
  Error: Unknown column 'order_lists.qty * orders.ex_rate_with_base' in 'field list'
  Please help me with the correct syntax
  How can I use column of order table in the sub query ?</p>