File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ public function tearDown()
77 Mockery::close ();
88
99 User::truncate ();
10+ Client::truncate ();
11+ Address::truncate ();
1012 Book::truncate ();
1113 Item::truncate ();
1214 Role::truncate ();
@@ -392,4 +394,27 @@ public function testHasOneHas()
392394 $ this ->assertCount (2 , $ users );
393395 }
394396
397+ public function testNestedKeys ()
398+ {
399+ $ client = Client::create (array (
400+ 'data ' => array (
401+ 'client_id ' => 35298 ,
402+ 'name ' => 'John Doe '
403+ )
404+ ));
405+
406+ $ address = $ client ->addresses ()->create (array (
407+ 'data ' => array (
408+ 'address_id ' => 1432 ,
409+ 'city ' => 'Paris '
410+ )
411+ ));
412+
413+ $ client = Client::where ('data.client_id ' , 35298 )->first ();
414+ $ this ->assertEquals (1 , $ client ->addresses ->count ());
415+
416+ $ address = $ client ->addresses ->first ();
417+ $ this ->assertEquals ('Paris ' , $ address ->data ['city ' ]);
418+ }
419+
395420}
Original file line number Diff line number Diff line change @@ -16,4 +16,9 @@ public function photo()
1616 {
1717 return $ this ->morphOne ('Photo ' , 'imageable ' );
1818 }
19+
20+ public function addresses ()
21+ {
22+ return $ this ->hasMany ('Address ' , 'data.client_id ' , 'data.address_id ' );
23+ }
1924}
You can’t perform that action at this time.
0 commit comments