Laravel合并/替换请求 - 文件

I've been using the merge() and replace() methods on the Request class. It's been working for the most part, but I was under the impression that merge() would add or override the existing parameters, while replace() wipes out all the parameters and adds the new array of ones passed in. However, they both work how I imagined merge() works. Am I missing something here?

Also, is there a way to merge() or replace() with a file, while still having the hasFile() method work? Basically what I'm doing is adapting a request from an API call. So I'm receiving the file in the request as one parameter, and remapping it to another parameter name so it matches what the backend is expecting. After using either method, the request looks correct at a glance when I do a dd($request->all()), but hasfile() returns false.

I did do some digging into the Http\Illuminate\Request class, and I think I'm finding that the issue is my file not being set it $_FILES. So it does work as intended I suppose.

With that being said, is there is particular way I can accomplish what I'm trying to do?

To Answer the first part of your question:

I went directly to the source and confirmed that the functions are indeed different:

Merge calls the add function which uses array_replace (php.net):

public function add(array $parameters = array())
{
    $this->parameters = array_replace($this->parameters, $parameters);
}

while

Replace simply replaces the whole variable(array)

public function replace(array $parameters = array())
{
    $this->parameters = $parameters;
}

So your initial impression is actually correct.