が含まれています。https://laravel.com/docs/5.3/collections#method-containsには、ララベルメソッドが使用されています。しかし、それは私のためには機能しません。ララベルコレクションには
foreach ($this->options as $option) {
if($options->contains($option->id)) {
dd('test');
}
}
dd($options);
次のようになります。dd($option->id);
の
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" => []
]
]
]
}
結果が10
です。
何が間違っている可能性がありますか?それとも良い方法がありますか?
コードはテキストとして投稿してください。画像はありません。 – Blag
@Blagはそれを変更しました! – Jamie