@@ -29,6 +29,20 @@ class Request
2929 */
3030 private array $ input = [];
3131
32+ /**
33+ * Define the post variables
34+ *
35+ * @var array
36+ */
37+ private array $ post = [];
38+
39+ /**
40+ * Define the query variables
41+ *
42+ * @var array
43+ */
44+ private array $ query = [];
45+
3246 /**
3347 * Define the bags instance
3448 *
@@ -91,19 +105,47 @@ public function capture()
91105 }
92106 }
93107
94- $ this ->input = array_merge ((array )$ data , $ _GET );
108+ $ this ->post = $ data ;
109+ $ this ->query = $ _GET ;
110+ $ this ->input = array_merge ((array ) $ data , $ this ->query );
95111
96112 foreach ($ this ->input as $ key => $ value ) {
97- if (is_string ($ value ) && strlen ($ value ) == 0 ) {
98- $ value = null ;
99- }
100-
101- $ this ->input [$ key ] = $ value ;
113+ $ this ->input [$ key ] = is_string ($ value ) && strlen ($ value ) == 0 ? null : $ value ;
102114 }
103115
104116 $ this ->capture = true ;
105117 }
106118
119+ /**
120+ * Retrieve query variables
121+ *
122+ * @param string|null $key
123+ * @return array
124+ */
125+ public function query (?string $ key = null ): array
126+ {
127+ if ($ key === null ) {
128+ return $ this ->query ;
129+ }
130+
131+ return $ this ->query [$ key ] ?? [];
132+ }
133+
134+ /**
135+ * Get posted data
136+ *
137+ * @param string|null $key
138+ * @return array
139+ */
140+ public function post (?string $ key = null ): array
141+ {
142+ if ($ key === null ) {
143+ return $ this ->post ;
144+ }
145+
146+ return $ this ->post [$ key ] ?? [];
147+ }
148+
107149 /**
108150 * Get Request header
109151 *
@@ -430,6 +472,11 @@ public function isAjax(): bool
430472 return $ content_type && str_contains ($ content_type , "application/json " );
431473 }
432474
475+ /**
476+ * Determine if is accept application/json
477+ *
478+ * @return boolean
479+ */
433480 public function wantsJson (): bool
434481 {
435482 $ accept = $ this ->getHeader ('accept ' );
0 commit comments