1$collection = collect([1, 2, 3, 4]);
2
3$filtered = $collection->filter(function ($value, $key) {
4 return $value > 2;
5});
6
7$filtered->all();
8
9// [3, 4]
1Sometime for such queries you need to disable the strict check
2 So inside config/database.php and inside mysql,
3 Set 'strict' => false,
4
5->select('user_id', DB::raw('SUM(points) as total_points'))
1$collection = collect([1, 2, 3, 4]);
2
3$collection->push(5);
4
5$collection->all();
6
7// [1, 2, 3, 4, 5]