i want to join some of table and get the data to display into datatables, i'm using yajra datatables.
my controller like this :
public function index(Request $request)
{
$customers = DB::table('customers')->select('id', 'name')->get();
$names = DB::table('reports')->join('customers', 'reports.customer_id', '=', 'customers.id')->select('customer_id', 'customers.name')->get();
// dd($names);
$reports = DB::table('reports')
->join('customers', 'reports.customer_id', '=', 'customers.id')
->select('reports.id', 'reports.date', 'reports.deal', 'reports.customer_information', 'reports.no_wa', 'reports.customer_id', 'customers.name', 'reports.qty', 'reports.order', 'reports.description')
->get();
return view('reports.create', compact('customers', 'reports'));
}
my index blade like this :
var table = $('.data-table').DataTable
({
processing: true,
serverSide: true,
ajax: "{{ route('reports.create') }}",
pageLength: 10,
lengthMenu: [5, 10, 20, 50, 100, 200, 500],
esponsive: true,
lengthChange: false,
autoWidth: false,
columns: [{
data: 'DT_RowIndex',
name: 'DT_RowIndex'
},
{
data: 'date',
name: 'date'
},
{
data: 'deal',
name: 'deal'
},
{
data: 'customer_information',
name: 'customer_information'
},
{
data: 'no_wa',
name: 'no_wa'
},
{
data: 'customer_id',
name: 'customer_id'
},
{
data: 'qty',
name: 'qty'
},
{
data: 'order',
name: 'order'
},
{
data: 'description',
name: 'description'
},
{
data: 'action',
name: 'action',
orderable: false,
searchable: false
},
]
});
so my problem is that the data on customer_id which I have joined to customers.name cannot appear. what steps should i do to bring up the data