Closed patrickgarsow-harvard closed 2 years ago
Hi @patrickgarsow-harvard -
Are you attempting to access $request within a controller method or something else? If the former, have you defined the method so that it accepts the parameter Request $request?
E.g.:
public function search(Request $request) {
}
Ref:
If you can share a link to a code file on Github where $request is failing, that would be helpful.
@susanBuck ,
Weirdly enough that I have things setup correctly with my function referencing Request $request
the documentation seems to break when you use the api referenced support facades. I only started using them because the officially sanctioned demo's via Laracast on PingCRM shows using this format to be consistent.
I did manage to solve my problem with some good old trial and error. I tried each of the methods defined in Illuminate\Support\Facades\Request
and output the results using dd(). Found the one that didn't output an array, or something unexpected but rather just the field I was looking for. Then I rinsed and repeated for every form entry. I was able to get the right results using a few different methods but found that input() was the best choice. So Request::input('name') for example.
Weirdly enough that I have things setup correctly with my function referencing Request $request the documentation seems to break when you use the api referenced support facades
Any chance you can share an example in your repo of this failing? I'd like to better understand the problem. I don't understand why you're unable to use $request.
Closing due to inactivity and because I think the original issue is solved. Feel free to re-open or start a new thread if there are any pending questions. 👍
I am having some trouble understanding the difference between the two different types of "Request." What I know is that you can't use both because an error is thrown. I have also read that the Facades is all inclusive of the Http\Request.
Lets assume that I need the Facades\Request because I don't know about everything that I would need to change from referenced code. I can't use
$request-><field_name>
because it doesn't exist. The only way thus far that I have been able to get it to work is to doRequest::all('<field_name>');
and that I don't feel is right.Any ideas? I have referenced the documentation but it looks less than complete: https://laravel.com/api/9.x/Illuminate/Support/Facades/Request.html