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()
7
7
Mockery::close ();
8
8
9
9
User::truncate ();
10
+ Client::truncate ();
11
+ Address::truncate ();
10
12
Book::truncate ();
11
13
Item::truncate ();
12
14
Role::truncate ();
@@ -392,4 +394,27 @@ public function testHasOneHas()
392
394
$ this ->assertCount (2 , $ users );
393
395
}
394
396
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
+
395
420
}
Original file line number Diff line number Diff line change @@ -16,4 +16,9 @@ public function photo()
16
16
{
17
17
return $ this ->morphOne ('Photo ' , 'imageable ' );
18
18
}
19
+
20
+ public function addresses ()
21
+ {
22
+ return $ this ->hasMany ('Address ' , 'data.client_id ' , 'data.address_id ' );
23
+ }
19
24
}
You can’t perform that action at this time.
0 commit comments