In my component I have
@foreach ($foodItems as $i)
<div wire:click="setSelectedFood({{ $i }})" class="flex items-center space-x-4 rtl:space-x-reverse bg-gray-100 rounded hover:ring-2 hover:ring-blue-500 p-3">
Backend:
public function setSelectedFood(mixed $food) {
dd((new Collection())->push(['name' => 'test'])->name);
$this->selectedFood = collect($food);
}
But
Property [name] does not exist on this collection instance.
Why is this happening? I want to use it like a collection via -> but it claims name doesn’t exist.
New contributor
ashdoestech is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.