I have the following query that I need to get a value from a nested array. I'm using laravel 5.4 in case that matters.
$usersstyle = DB::connection('mysql2')
->table('wp_rg_lead_detail')
->where('lead_id', $collection->id)
->get();
dd($usersstyle);
This has an output of:
Collection {#396 ▼
#items: array:49 [▼
0 => {#406 ▶}
1 => {#407 ▶
18 => {#428 ▼
+"id": 655
+"lead_id": 67
+"form_id": 8
+"field_number": 51.0
+"value": "Yes"
}
19 => {#429 ▼
+"id": 656
+"lead_id": 67
+"form_id": 8
+"field_number": 6.1
+"value": "Sleeveless"
}
20 => {#430 ▼
+"id": 657
+"lead_id": 67
+"form_id": 8
+"field_number": 6.2
+"value": "Jacket"
}
21 => {#431 ▼
+"id": 658
+"lead_id": 67
+"form_id": 8
+"field_number": 6.3
+"value": "Cardigan"
}
22 => {#432 ▶}
I have tried the following, but it returns the 1st instance of the field_number, and ignores the 6.2 and 6.3. How do I do this and keep all the floats as keys.
$keyed = $usersstyle->keyBy('field_number')->all();
I want to get something like the below. With out a foreach loop to display that.
echo $6.3->value;
with the result being Cardigan
I have also used
$grabvalues = $usersstyle->whereIn('field_number', 80.3)->toArray();
this returns an array or if i drop the toArray a collection that I still need to loop through to get the value
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2twJ36u
via IFTTT
Aucun commentaire:
Enregistrer un commentaire