I have such a model -
$feature_project = FeatureProject::select('feature_id') ->where('project_id', $project->id) ->get();
And if I return it, I get a conclusion like this -
[ { "feature_id": 2 }, { "feature_id": 4 }, { "feature_id": 9 } ]
But I want t to be output as follows:
[2,4,9]
So, I need to convert the output.
But I donβt find a way without using the for-each loop (I create a temp array, push all the elements into this array from the current array with the for-each loop).
But I think there is a smarter way to do this in Laravel.
I think the Laravel Collection is used for this purpose.
source share