File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,31 @@ public function it_returns_all_records_with_the_relation_when_called_without_par
2626 $ this ->assertCount (60 , $ response ->json ()['data ' ]);
2727 }
2828
29+ /** @test */
30+ public function it_can_search_has_one_through_relation ()
31+ {
32+ $ response = $ this ->call ('GET ' , '/relations/hasOneThroughSearchRelation ' , [
33+ 'columns ' => [
34+ [
35+ 'data ' => 'heart.size ' ,
36+ 'searchable ' => true ,
37+ 'search ' => [
38+ 'value ' => 'heart-1 '
39+ ]
40+ ]
41+ ],
42+ ]);
43+
44+ $ response ->assertJson ([
45+ 'draw ' => 0 ,
46+ 'recordsTotal ' => 60 ,
47+ 'recordsFiltered ' => 33 ,
48+ ]);
49+
50+ $ this ->assertArrayHasKey ('heart ' , $ response ->json ()['data ' ][0 ]);
51+ $ this ->assertCount (33 , $ response ->json ()['data ' ]);
52+ }
53+
2954 /** @test */
3055 public function it_returns_all_records_with_the_deleted_relation_when_called_with_withtrashed_parameter ()
3156 {
@@ -101,6 +126,10 @@ protected function setUp(): void
101126 return $ datatables ->eloquent (Post::with ('heart ' )->select ('posts.* ' ))->toJson ();
102127 });
103128
129+ $ this ->app ['router ' ]->get ('/relations/hasOneThroughSearchRelation ' , function (DataTables $ datatables ) {
130+ return $ datatables ->eloquent (Post::with ('heart ' ))->addColumns (['hearts.size ' ])->toJson ();
131+ });
132+
104133 $ this ->app ['router ' ]->get ('/relations/hasOneThroughWithTrashed ' , function (DataTables $ datatables ) {
105134 return $ datatables ->eloquent (Post::with (['heart ' => function ($ query ) {
106135 $ query ->withTrashed ();
You can’t perform that action at this time.
0 commit comments