1 | <?php |
||
10 | abstract class Responder implements Responsable |
||
11 | { |
||
12 | /** |
||
13 | * The response payload. |
||
14 | * |
||
15 | * @var mixed |
||
16 | */ |
||
17 | protected $payload; |
||
18 | |||
19 | /** |
||
20 | * Laraflash for flashing to session. |
||
21 | * |
||
22 | * @var \DevMarketer\LaraFlash\LaraFlash |
||
23 | */ |
||
24 | protected $flash; |
||
25 | |||
26 | /** |
||
27 | * Construct a new base Responder. |
||
28 | * |
||
29 | * @param \Illuminate\Http\Request $request |
||
30 | * @param \DevMarketer\LaraFlash\LaraFlash $flash |
||
31 | */ |
||
32 | public function __construct(Request $request, LaraFlash $flash) |
||
37 | |||
38 | /** |
||
39 | * Create an HTTP response that represents the object. |
||
40 | * |
||
41 | * @param \Illuminate\Http\Request $request |
||
42 | * |
||
43 | * @return \Illuminate\Http\Response |
||
44 | */ |
||
45 | public function toResponse($request) |
||
49 | |||
50 | /** |
||
51 | * Send a response. |
||
52 | * |
||
53 | * @return mixed |
||
54 | */ |
||
55 | abstract public function respond(); |
||
56 | |||
57 | /** |
||
58 | * Add the payload to the response. |
||
59 | * |
||
60 | * @param mixed $payload |
||
61 | * |
||
62 | * @return $this |
||
63 | */ |
||
64 | public function withPayload($payload) |
||
70 | |||
71 | /** |
||
72 | * Add the request to the response. |
||
73 | * |
||
74 | * @param \Illuminate\Http\Request $request |
||
75 | * |
||
76 | * @return $this |
||
77 | */ |
||
78 | public function withRequest(Request $request) |
||
84 | |||
85 | /** |
||
86 | * Flash data to the session. |
||
87 | * |
||
88 | * @param string $key |
||
89 | * @param mixed $value |
||
90 | */ |
||
91 | protected function flash($message, array $options = []) |
||
95 | } |
||
96 |