#passing in collection a as function param gets converted into array

7 messages · Page 1 of 1 (latest)

north frost
#

view

<button wire:click="setSelected({{ $myCollection }})">test<button>

model

public $myCollection;

public function setSelected($myCollection)
{
    $this->myCollection = $myCollection; // but it converts it into an array :(
}
keen light
#

$this->myCollection = collect($myCollection);

north frost
#

i have already lost the information about what models they are

#

the issue is that i want to know from what model the item comes

#

because the collection im passing to the function has different models

#

and then in my view i have to check the type of the model:

{{-- if it's a Item model --}}
@if (class_basename($item) == 'Item')