Search code examples
ajaxlaraveldatatablecontrolleryajra-datatable

join data in datatable (laravel)


need to join two data and compile to show in datatable but i dont know what is wrong in my code

controller

        $data = DB::table('items')
   ->join('shipments', 'shipments.shp_no','=','items.shp_no_for_it')
   ->select('items.it_arabic_name', 'shipments.shp_destination_shipping_fees')
   ->get();
    return Datatables::of($data)
    ->make(true);

ajax

columns: [

    {data: 'items.it_arabic_name',
      render: function ( data, type, row ) {
        return row.items.it_arabic_name + ' ' + row.shipments.shp_destination_shipping_fees;
   }
    }]

get this error

i get this error


Solution

  • solved

    columns: [
    
        {data: 'items.it_arabic_name',
          render: function ( data, type, row ) {
            return row.it_arabic_name + ' ' + row.shp_destination_shipping_fees;
       }
    }]