Is there a way to filter a collection returned by database query on Laravel?
Returned collection is this
1 => Person {#310 ▼
#table: "person"
#attributes: array:15 [▼
"name" => "Jon Doe"
"timeavailable" => "1,2,3,4,5,6,7,8"
2 => Person {#310 ▼
#table: "person"
#attributes: array:15 [▼
"name" => "Jon Moe"
"timeavailable" => "1,2,5,7,8"
Here, I want to filter the timeavailable
attribute. I only want to show results for 1,2,3
. Is there a way to filter this collection so that I only get something like this
1 => Person {#310 ▼
#table: "person"
#attributes: array:15 [▼
"name" => "Jon Doe"
"timeavailable" => "1,2,3"
2 => Person {#310 ▼
#table: "person"
#attributes: array:15 [▼
"name" => "Jon Moe"
"timeavailable" => "1,2"
So, the filtered collection will have only 1,2,3
inclusions.