You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
22
{
23
$this->request = $request;
24
}
25
26
/**
27
* Create an HTTP response that represents the object.
28
*
29
* @param \Illuminate\Http\Request $request
30
*
31
* @return \Illuminate\Http\Response
32
*/
33
public function toResponse($request)
34
{
35
return $this->respond();
36
}
37
38
/**
39
* Send a response.
40
*
41
* @return mixed
42
*/
43
abstract public function respond();
44
45
/**
46
* Add the payload to the response.
47
*
48
* @param mixed $payload
49
*
50
* @return $this
51
*/
52
public function withPayload($payload)
53
{
54
$this->payload = $payload;
55
56
return $this;
57
}
58
59
/**
60
* Add the request to the response. Allows FormRequest objects to be added to the responder.
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().