File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
tests/lib/Integration/Routing Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,13 @@ public function replace(iterable $parameters): self
103103 $ copy = clone $ this ;
104104
105105 foreach ($ parameters as $ key => $ value ) {
106- $ copy ->namespace = \str_replace ('{ ' . $ key . '} ' , $ value , $ copy ->namespace );
106+ $ routeParamValue = $ value ;
107+
108+ if ($ value instanceof UrlRoutable) {
109+ $ routeParamValue = $ value ->getRouteKey ();
110+ }
111+
112+ $ copy ->namespace = \str_replace ('{ ' . $ key . '} ' , $ routeParamValue , $ copy ->namespace );
107113 }
108114
109115 return $ copy ;
Original file line number Diff line number Diff line change 2020use CloudCreativity \LaravelJsonApi \Routing \RouteRegistrar ;
2121use CloudCreativity \LaravelJsonApi \Tests \Integration \TestCase ;
2222use DummyApp \Post ;
23+ use DummyApp \User ;
2324use Illuminate \Support \Arr ;
2425
2526/**
@@ -77,4 +78,16 @@ public function testManual(): void
7778 Arr::get ($ data , 'data.links.self ' )
7879 );
7980 }
81+
82+ public function testModelBinding (): void
83+ {
84+ $ post = factory (Post::class)->create ();
85+ $ user = factory (User::class)->create ();
86+ $ data = json_api (null , null , ['tenant ' => $ user ])->encoder ()->serializeData ($ post );
87+
88+ $ this ->assertSame (
89+ url ('/foo/2/api/posts ' , $ post ),
90+ Arr::get ($ data , 'data.links.self ' )
91+ );
92+ }
8093}
You can’t perform that action at this time.
0 commit comments