code: public function scopeWhereUser($query, $userId)
      {
          return $query->join(
                  Config::get('shop.order_table'),
                  Config::get('shop.order_table') . '.id',
                  '=',
                  Config::get('shop.transaction_table') . '.order_id'
              )
              ->where(Config::get('shop.order_table') . '.user_id', $userId);
      }
docs: Scopes to get transactions from user.
  
  @return \Illuminate\Database\Eloquent\Builder