Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

346
Views
get data with joining table in laravel and yajra datatable

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!