title: Cannot get data in Laravel
body: <p>I have code like this in my Laravel <code>index.blade</code> for showing the data from query list of product bundle:</p>
  <pre><code>&lt;div class=&quot;kt-portlet&quot;&gt;
      &lt;div class=&quot;kt-portlet__body&quot;&gt;
          &lt;table id='table_product' class=&quot;table table-bordered table-striped table-condensed flip-content&quot;&gt;
              &lt;thead class=&quot;flip-content&quot;&gt;
                  &lt;tr&gt;
                      &lt;th class=&quot;no-sort&quot;&gt;Action&lt;/th&gt;
                      &lt;th class=&quot;&quot;&gt;Name&lt;/th&gt;
                      &lt;th class=&quot;&quot;&gt;Price&lt;/th&gt;
                      @if (Auth::user()-&gt;is_super_admin)
                          &lt;th class=&quot;no-sort&quot;&gt;Hub&lt;/th&gt;
                      @endif
                      &lt;th class=&quot;&quot;&gt;Status&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  @stop
  
  @section('page_css')
  &lt;style type=&quot;text/css&quot;&gt;
  .old_price {
    color: red;
    text-decoration: line-through;
    font-style: italic;
  }
  &lt;/style&gt;
  @endsection
  
  @section('add_js')
  @parent
  &lt;script type=&quot;text/javascript&quot;&gt;
  
      var table;
  
      $(document).ready(function () {
          {!! $form-&gt;printJs(); !!}
  
          $('#search_btn').click(function () {
              table.ajax.reload(function () {
                  $('#search_btn').removeClass('kt-spinner kt-spinner--right kt-spinner--sm kt-spinner--light').attr('disabled', false);
                  $('.no-sort').removeClass('sorting_asc');
              });
          });
  
          table = $(&quot;#table_product&quot;).DataTable({
              searchDelay: 500,
              filter: true,
              dom: `&lt;'row'&lt;'col-sm-12'tr&gt;&gt;
                          &lt;'row'&lt;'col-sm-12 col-md-5'i&gt;&lt;'col-sm-12 col-md-7 dataTables_pager'lp&gt;&gt;`,
              responsive: false,
              pageLength: 10,
              processing: true,
              serverSide: true,
              ajax: {
                &quot;url&quot;: &quot;{{ URL::to('/') }}/product-bundle/data&quot;,
                &quot;type&quot;: &quot;POST&quot;,
                &quot;headers&quot;: {
                    'X-CSRF-TOKEN': $('meta[name=&quot;csrf-token&quot;]').attr('content')
                },
                &quot;data&quot;: function (d) {
                    d.search = $('#global_search').val();
                    d.status = $('#status').val();
                    d.hub_id = $('#hub_id').val();
                }
              },
              columns: [{
                      data: &quot;id&quot;
                  },
                  {
                      data: &quot;name&quot;
                  },
                  {
                      data: &quot;price&quot;
                  },
               @if (Auth::user()-&gt;is_super_admin)
                  {
                  data: &quot;hub.name&quot;
                  },
                          @endif
                  {
                      data: &quot;status&quot;
                  }],
              columnDefs: [
                  {
                      targets: 0,
                      orderable: false,
                      render: function (data, type, row) {
                          return '&lt;a href=&quot;/product-bundle/' + row['id'] + '&quot; class=&quot;btn btn-sm btn-outline-info btn-pill&quot;&gt;DETAIL ...&lt;/a&gt;';
                      }
                  },
                  {
                      targets: -1,
                      render: function (data, type, row) {
                          if (row['status'] == '1') {
                              return  'Active'
                          }
                          return 'Inactive'
                      }
                  },
                  {
                      &quot;targets&quot;: 'no-sort',
                      &quot;orderable&quot;: false,
                  },
                  {
                      targets: 'hidden',
                      visible: false,
                  }
              ],
              &quot;initComplete&quot;: function (settings, json) {
                  $('.no-sort').removeClass('sorting_asc');
                  table.columns.adjust().draw();
                  $('.no-sort').removeClass('sorting_asc')
              }
          });
      });
  &lt;/script&gt;
  </code></pre>
  <p>But when I see in my apps, I got error like my apps cannot get the value from <code>hub.name</code>, like my <code>hub.name</code> is &quot;&quot;. So I cannot get the value of <code>hub.name</code>. In my models I have set <code>hub_id</code> as. When I inspect I got error like this:</p>
  <blockquote>
  <p>DataTables warning: table id=table_product - Requested unknown parameter 'hub.name' for row 0, column 3. For more information about this error, please see</p>
  </blockquote>
  <pre><code>public function hub()
  {
      return $this-&gt;belongsTo('App\Models\Hub', 'hub_id')-&gt;select(['id', 'name', 'is_3rd_party']);
  }
  </code></pre>
  <p>And here my repository:</p>
  <pre><code>public function list($limit = 10, $page = 1, $sort = &quot;&quot;, $q = &quot;&quot;, $params_extra = []) {
      $query = ProductBundle::select();
      $query-&gt;with('product_bundle_detail.product');
      $query-&gt;with('hub');
      if (!empty($params_extra)) {
          $query-&gt;where($params_extra);
      }
      $total = $query-&gt;count();
  
      if ($q != &quot;&quot;) {
          $query-&gt;where(function ($query) use ($q) {
              return $query-&gt;where('name', 'like', &quot;%$q%&quot;);
          });
      }
      if ($sort != &quot;&quot;) {
          $sort = explode(':', $sort);
          $query-&gt;orderBy($sort[0],@$sort[1]);
      }
      $total_filtered = $query-&gt;count();
      $limit = ($limit == -1) ? 10 : $limit;
      if (!is_null($limit)) {
          $offset = ($page - 1) * $limit;
          $query-&gt;offset($offset)-&gt;limit($limit);
      }
      $data = $query-&gt;get()-&gt;map(function($value){
          $value = General::encode_ids($value-&gt;toArray());
          $value['images'] = json_decode($value['images']);
          $value['images_thumb'] = json_decode($value['images_thumb']);
          if (@$value['product_bundle_detail']) {
              foreach ($value['product_bundle_detail'] as $key1 =&gt; $product_bundle_detail) {
                  if (@$product_bundle_detail['product']['images']) {
                      $value['product_bundle_detail'][$key1]['product']['images'] = json_decode($value['product_bundle_detail'][$key1]['product']['images']);
                  }
              }
          }
          return $value;
      });
      return [
          'data' =&gt; $data,
          'total_rows' =&gt; $total,
          'total_filtered' =&gt; $total_filtered,
      ];
  }
  </code></pre>
  <p>I have try to search where is the code error, But I cannot see where is the problem. Can anyone help me for fix this issue?</p>