In my laravel
-application I have two arrays, one called "headers" and one called "rows" and I only want the data from the "row" array which is based on the key from the "headers" array.
So here are my arrays:
"rows" => array:2 [
0 => array:6 [
"Company name" => "Universal"
"Address" => "Some address"
"Zipcode" => 12122
"City" => "Some city"
"Phonenumber" => 12345678
"Email" => "[email protected]"
],
1 => array:6 [
"Company name" => "Warner Bros."
"Address" => "another address"
"Zipcode" => 12122
"City" => "city abc"
"Phonenumber" => 12345678
"Email" => "[email protected]"
]
],
"headers" => array:4 [
0 => array:2 [
"name" => "Company name"
"data" => array:1 [
"value" => "company_name"
]
],
1 => array:2 [
"name" => "Adresse"
"data" => array:1 [
"value" => "address"
]
]
]
So far so good, now I only want the data from the "rows"-array which is selected from the "headers" array, so that I can display them like this in my frontend:
Company name | Address
----------------------------------
Universal | Some address
Warner Bros. | Another address
So, how can I store them in the database? My Model structure is this:
Entry::create([
'company_name' => request()->company_name ?? null,
'address' => request()->address ?? null,
'zipcode' => request()->zipcode ?? null,
'city' => request()->city ?? null,
'number' => request()->number ?? null,
'email' => request()->email ?? null
]);
Thanks in advance...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…