I am working on a project using Laravel 5.2. I have a search and CSV export functions. I want to export the latest search result as a CSV file if I click on CSV export link.
My logic is : I pass the search result to front-end (index.blade.php) and store the value in a hidden input field and when I click CSV export link, I will pass this hidden input to the CSV export controller and do the printing operation.
My problem is: how can I change these data format(the hidden input data)
[
{
"memberId": 9,
"area_id": 2,
"status_id": 0,
"reference_id": 0,
"productname": null,
"picaluminum": null,
"companyName": "てすと",
"name": "てすと会社",
"job": 3,
"relationJob": null,
"subJobCategory": null,
"busyo": null,
"eMail": "y_ikegami@gmail.com",
"password": "password",
"zip1": "530",
"zip2": "0001",
"pref": 27,
"prefStr": "大阪府",
"address1": "大阪市北区梅田2-2-2",
"address2": "20F",
"tel1": "06",
"tel2": "1111",
"tel3": "1111",
"fax1": "06",
"fax2": "9999",
"fax3": "9999",
"siteUrl": "http://www.google/",
"medium": "|1|",
"pdf": "|1|",
"created_at": "2015-07-27 18:23:28",
"updated_at": null
},
{
"memberId": 5275,
"area_id": 2,
"status_id": 3,
"reference_id": 4,
"productname": "yonascare",
"picaluminum": "",
"companyName": "ddd",
"name": "Test Queserser",
"job": null,
"relationJob": null,
"subJobCategory": null,
"busyo": null,
"eMail": null,
"password": null,
"zip1": null,
"zip2": null,
"pref": null,
"prefStr": null,
"address1": "zzzzzz",
"address2": null,
"tel1": null,
"tel2": null,
"tel3": null,
"fax1": null,
"fax2": null,
"fax3": null,
"siteUrl": null,
"medium": null,
"pdf": null,
"created_at": "2018-07-06 06:42:20",
"updated_at": "2018-07-06 06:42:20"
},
{
"memberId": 5279,
"area_id": 2,
"status_id": 1,
"reference_id": 1,
"productname": "yonascare",
"picaluminum": "hello",
"companyName": "yonas3",
"name": "Test Queserser",
"job": null,
"relationJob": 1,
"subJobCategory": 6,
"busyo": null,
"eMail": null,
"password": null,
"zip1": null,
"zip2": null,
"pref": null,
"prefStr": null,
"address1": "zzzzzz",
"address2": null,
"tel1": null,
"tel2": null,
"tel3": null,
"fax1": null,
"fax2": null,
"fax3": null,
"siteUrl": null,
"medium": null,
"pdf": null,
"created_at": "2018-07-06 06:57:12",
"updated_at": "2018-07-06 07:04:51"
}
]
To the following data format (Laravel Query format)
Collection {#403 ▼
#items: array:3 [▼
0 => MemberMaster {#399 ▼
#table: "memberMasternewdata"
#primaryKey: "memberId"
#fillable: array:10 [▶]
#connection: null
#keyType: "int"
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:31 [▼
"memberId" => 9
"area_id" => 2
"status_id" => 0
"reference_id" => 0
"productname" => null
"picaluminum" => null
"companyName" => "てすと"
"name" => "てすと会社"
"job" => 3
"relationJob" => null
"subJobCategory" => null
"busyo" => null
"eMail" => "y_ikegami@gmail.com"
"password" => "password"
"zip1" => "530"
"zip2" => "0001"
"pref" => 27
"prefStr" => "大阪府"
"address1" => "大阪市北区梅田2-2-2"
"address2" => "20F"
"tel1" => "06"
"tel2" => "1111"
"tel3" => "1111"
"fax1" => "06"
"fax2" => "9999"
"fax3" => "9999"
"siteUrl" => "http://www.google.com/"
"medium" => "|1|"
"pdf" => "|1|"
"created_at" => "2015-07-27 18:23:28"
"updated_at" => null
]
#original: array:31 [▶]
#relations: []
#hidden: []
#visible: []
#appends: []
#guarded: array:1 [▶]
#dates: []
#dateFormat: null
#casts: []
#touches: []
#observables: []
#with: []
#morphClass: null
+exists: true
+wasRecentlyCreated: false
}
1 => MemberMaster {#400 ▶}
2 => MemberMaster {#401 ▶}
]
}
Thank you in advance!!