I am working on a Laravel DataTable. I have an array of the field customer.
I want to fetch the data from the other table using a foreach
loop. How can I fetch data from another table in my for each element of the array?
$quotations = $this->quotationRepository->getAll()
->where([
['status', '!=', 'Draft Quotation']
])
->where('deleted', '=', '0')
->with('user', 'customer')
->get()
->map(function ($quotation) use ($dateFormat) {
return [
'id' => $quotation->id,
'quotations_number' => $quotation->quotations_number,
//'customer' => $cl,
'customer' => unserialize($quotation->customer_id),
'final_price' => $quotation->final_price,
'date' => date($dateFormat, strtotime($quotation->date)),
'exp_date' => date($dateFormat, strtotime($quotation->exp_date)),
'payment_term' => $quotation->payment_term,
'status' => $quotation->status
];
});