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