Skip to content

Receiving Models in Action Handle method does not work as stated in the docs #1266

@Naoray

Description

@Naoray

In multiple locations the documentation for actions states, that the following works:

public function handle(ActionFields $fields, Collection $models)
{
    foreach ($models as $model) {
        (new AccountData($model))->send($fields->subject);
    }
}

Because the $models Collection comes back as JSON data only the following approach worked for me:

public function handle(ActionFields $fields, Collection $models)
{
    AccountData::hydrate(json_decode($models, true))
            ->each(function ($accountData) {
                $accountData->send();
            });
}

EDIT: Getting the following error when trying to do it like in the docu:
image

Can you confirm this issue? Want to have a confirmation before making a PR on this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions