Ich benutze die Laravel contains
Methode für eine Sammlung https://laravel.com/docs/5.3/collections#method-contains. Aber es funktioniert nicht für mich.Laravel Sammlung enthält
foreach ($this->options as $option) {
if($options->contains($option->id)) {
dd('test');
}
}
dd($options);
sieht wie folgt aus:
Collection {#390
#items: array:1 [
0 => array:3 [
0 => array:7 [
"id" => 10
"slug" => "test"
"name" => "test"
"poll_id" => 4
"created_at" => "2016-11-12 20:42:42"
"updated_at" => "2016-11-12 20:42:42"
"votes" => []
]
1 => array:7 [
"id" => 11
"slug" => "test-1"
"name" => "test"
"poll_id" => 4
"created_at" => "2016-11-12 20:42:42"
"updated_at" => "2016-11-12 20:42:42"
"votes" => []
]
2 => array:7 [
"id" => 12
"slug" => "test-2"
"name" => "test"
"poll_id" => 4
"created_at" => "2016-11-12 20:42:42"
"updated_at" => "2016-11-12 20:42:42"
"votes" => []
]
]
]
}
Ergebnis dd($option->id);
10
ist.
Was könnte falsch sein? Oder gibt es einen besseren Weg?
Code sollte als Text, nicht Bild bitte geschrieben werden ... – Blag
@Blag änderte es! – Jamie