我对导出数据有疑问。
我正在使用带有laravel 5.4的maatwebsite。我有一个这样的数组:
array:8 [▼
"company_id" => "2"
"company_name" => "Test Company2"
"survey_id" => "1"
"survey_name" => "ELMAO"
"customer_id" => "5"
"customer_first_name" => "Lol"
"customer_last_name" => "Kek"
"questions" => array:2 [▼
0 => array:4 [▼
"question_name" => "1"
"question_title" => ""
"response_text" => "2"
"screenshot_url" => "iVBORw0KGgoAAAANSUhEUgAAAeAAAAHvCAYAAACMggxAAAAgAElEQVR4XuydCZwdVZX/f/W2XpLOvq9kYwkh7BACjKCCrAEMmywqiqij4gAqOjoqo6OOOgoDKjgqyoCIiIp/GEH2fcdAyB5IyL4nvfdb6//5nXqv ▶"
]
1 => array:4 [▼
"question_name" => "7"
"question_title" => "Keek!"
"response_text" => "2"
"screenshot_url" => "iVBORw0KGgoAAAANSUhEUgAAAeAAAAHvCAYAAACMggxAAAAgAElEQVR4XuydB7hcZbX+3z3tlPRGeg+EQAhBSkKAK6ggUkIJTYqKIupV8Qooer1XRb3qVa/CRRFsKBdERFT8g4D03iEQ0kggIb2enH6mz/95156J ▶"
]
]
]
如何将此数据导出为CSV文件并将其作为JSON字符串导出?
答案 0 :(得分:0)
从eloquent模型中检索数据时,您已构建函数以将其设置为JSON。 https://laravel.com/docs/5.5/eloquent-serialization#serializing-to-arrays