1 | <?php |
||
8 | abstract class Responder implements Responsable |
||
9 | { |
||
10 | /** @var mixed */ |
||
11 | protected $payload; |
||
12 | |||
13 | /** @var \Illuminate\Http\Request */ |
||
14 | protected $request; |
||
15 | |||
16 | /** |
||
17 | * Construct a new base Responder. |
||
18 | * |
||
19 | * @param \Illuminate\Http\Request $request |
||
20 | */ |
||
21 | public function __construct(Request $request) |
||
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) |
||
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) |
||
58 | |||
59 | /** |
||
60 | * Add the request to the response. Allows FormRequest objects to be added to the responder. |
||
61 | * |
||
62 | * @param \Illuminate\Http\Request $request |
||
63 | * |
||
64 | * @return $this |
||
65 | */ |
||
66 | public function withRequest(Request $request) |
||
72 | } |
||
73 |