@@ -987,6 +987,74 @@ public function it_ignores_query_string_parameters_using_unnamed_routes()
987
987
], $ response ->original );
988
988
}
989
989
990
+ /** @test */
991
+ public function it_prefers_route_parameters_before_query_string_parameters_with_the_same_name_in_unnamed_routes ()
992
+ {
993
+ $ this ->withoutExceptionHandling ();
994
+ $ this ->setSupportedLocales (['en ' , 'nl ' ]);
995
+
996
+ $ model = (new ModelOneWithRouteBinding ([
997
+ 'slug ' => [
998
+ 'en ' => 'en-slug ' ,
999
+ 'nl ' => 'nl-slug ' ,
1000
+ ],
1001
+ ]))->setKeyName ('slug ' );
1002
+
1003
+ App::instance (ModelOneWithRouteBinding::class, $ model );
1004
+
1005
+ Route::localized (function () use ($ model ) {
1006
+ Route::get ('route/{slug} ' , function (ModelOneWithRouteBinding $ slug ) {
1007
+ return [
1008
+ 'current ' => Route::localizedUrl (),
1009
+ 'en ' => Route::localizedUrl ('en ' ),
1010
+ 'nl ' => Route::localizedUrl ('nl ' ),
1011
+ ];
1012
+ })->middleware (['web ' ]);
1013
+ });
1014
+
1015
+ $ response = $ this ->call ('GET ' , '/en/route/en-slug?slug=duplicate ' );
1016
+ $ response ->assertOk ();
1017
+ $ this ->assertEquals ([
1018
+ 'current ' => URL ::to ('/en/route/en-slug?slug=duplicate ' ),
1019
+ 'en ' => URL ::to ('/en/route/en-slug?slug=duplicate ' ),
1020
+ 'nl ' => URL ::to ('/nl/route/nl-slug?slug=duplicate ' ),
1021
+ ], $ response ->original );
1022
+ }
1023
+
1024
+ /** @test */
1025
+ public function it_prefers_route_parameters_before_query_string_parameters_with_the_same_name_in_named_routes ()
1026
+ {
1027
+ $ this ->withoutExceptionHandling ();
1028
+ $ this ->setSupportedLocales (['en ' , 'nl ' ]);
1029
+
1030
+ $ model = (new ModelOneWithRouteBinding ([
1031
+ 'slug ' => [
1032
+ 'en ' => 'en-slug ' ,
1033
+ 'nl ' => 'nl-slug ' ,
1034
+ ],
1035
+ ]))->setKeyName ('slug ' );
1036
+
1037
+ App::instance (ModelOneWithRouteBinding::class, $ model );
1038
+
1039
+ Route::localized (function () use ($ model ) {
1040
+ Route::get ('route/{slug} ' , function (ModelOneWithRouteBinding $ slug ) {
1041
+ return [
1042
+ 'current ' => Route::localizedUrl (),
1043
+ 'en ' => Route::localizedUrl ('en ' ),
1044
+ 'nl ' => Route::localizedUrl ('nl ' ),
1045
+ ];
1046
+ })->middleware (['web ' ])->name ('test ' );
1047
+ });
1048
+
1049
+ $ response = $ this ->call ('GET ' , '/en/route/en-slug?slug=duplicate ' );
1050
+ $ response ->assertOk ();
1051
+ $ this ->assertEquals ([
1052
+ 'current ' => URL ::to ('/en/route/en-slug?slug=duplicate ' ),
1053
+ 'en ' => URL ::to ('/en/route/en-slug?slug=duplicate ' ),
1054
+ 'nl ' => URL ::to ('/nl/route/nl-slug?slug=duplicate ' ),
1055
+ ], $ response ->original );
1056
+ }
1057
+
990
1058
/** @test */
991
1059
public function it_allows_optional_parameters_with_named_routes ()
992
1060
{
0 commit comments