dongping4461 2019-02-02 14:01
浏览 45

从DataTable中的每个数组元素的另一个表中获取数据

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
        ];
    });
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有赏,i卡绘世画不出
    • ¥15 如何用stata画出文献中常见的安慰剂检验图
    • ¥15 c语言链表结构体数据插入
    • ¥40 使用MATLAB解答线性代数问题
    • ¥15 COCOS的问题COCOS的问题
    • ¥15 FPGA-SRIO初始化失败
    • ¥15 MapReduce实现倒排索引失败
    • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
    • ¥15 找一位技术过硬的游戏pj程序员
    • ¥15 matlab生成电测深三层曲线模型代码