File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -22,16 +22,21 @@ public function __construct(\MareaTurbo\Route $route)
2222 */
2323 public function all ()
2424 {
25- return get_object_vars ( $ this );
25+ return $ this -> route -> getInputBag ( );
2626 }
2727
2828 /**
2929 *
3030 */
3131 public function only (array $ keys = [])
3232 {
33- return array_filter ($ keys , function ($ key ) {
34- return $ this ->$ key ;
35- });
33+ $ inputBag = $ this ->route ->getInputBag ();
34+ $ filtered = [];
35+ foreach ($ keys as $ key ) {
36+ if (array_key_exists ($ key , $ inputBag )) {
37+ $ filtered [$ key ] = $ inputBag [$ key ];
38+ }
39+ }
40+ return $ filtered ;
3641 }
3742}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ class Route
1313 public String $ path ;
1414 public HttpMethod $ method ;
1515 public string $ name ;
16+ protected array $ inputBag ;
1617
1718 /**
1819 *
@@ -45,6 +46,7 @@ public function isMatch(Route $route): bool
4546 if (substr ($ value , 0 , 1 ) != "{ " || substr ($ value , -1 ) != "} " ) {
4647 return false ;
4748 }
49+ $ this ->inputBag [substr ($ value , 1 , -1 )] = $ accessedRoute [$ key ];
4850 }
4951 }
5052 return true ;
@@ -60,4 +62,9 @@ public function routeStringToArray(string $string): array
6062 }
6163 return explode ('/ ' , $ string );
6264 }
65+
66+ public function getInputBag (): array
67+ {
68+ return $ this ->inputBag ;
69+ }
6370}
You can’t perform that action at this time.
0 commit comments