I think the problem here is,
In your collections the items property is empty, which is an array inside the collection. The reverse function uses this items property.
so if you want to use all the collection class's functions, set the items array instead of $some_array.
public function setArray(){
$this->items = [1,2,3];
}
or override the reverse function like this
public function reverse()
{
return new static(array_reverse($this->some_array));
}
the first solution is better.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community