request-factories icon indicating copy to clipboard operation
request-factories copied to clipboard

Support Array of Files

Open rabrowne85 opened this issue 8 months ago • 0 comments

It is not possible to have a request factory where a key has an array of files e.g.,:


public function files(): array
{
    return [
        'documents' => [
            $this->image('file.jpg'),
            $this->image('file2.jpg'),
            $this->file('file.pdf'),
        ],
    ];
}

This PR adds support for this by updating the Result.php to adjust the filtering of inputs() and files() such that arrays of files are found in files() and NOT in inputs(). This does not appear to break existing tests and should be backwardly compatible.

This ensures that the files are passed correctly in the request and thus can be found by the controller.

I've adjusted the test suite to add new checks for the array of files, and existing tests continue to pass.

rabrowne85 avatar May 02 '25 20:05 rabrowne85