Skip to content

Component with public property with Collection type #384

@lukasleitsch

Description

@lukasleitsch

A Modal Component with a Collection as public property can not be created and fails with Method Illuminate\Support\Collection::resolveRouteBinding does not exist. in

if (! $model = $instance->resolveRouteBinding($parameterValue)) {

class AddNewParticipants extends ModalComponent
{
  public Collection $participants;

  public function mount(array $participants = [])
  {
    $this->participants = User::findMany($participants);
  }
}
<button
  wire:click="$dispatch('openModal', { component: 'add-new-participants', arguments: { participants: [2, 4, 5] } })"
>
  @lang('Add')
</x-button>

The Modal tries to resolve the parameter participants and finds the parameter as public property with the type Collection. It seems that this type is not handled yet.

In this case, I would like to care of resolving the parameters in the mount method and skip the resolving of the Modal Component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions