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
26
26
$ this ->assertCount (60 , $ response ->json ()['data ' ]);
27
27
}
28
28
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
+
29
54
/** @test */
30
55
public function it_returns_all_records_with_the_deleted_relation_when_called_with_withtrashed_parameter ()
31
56
{
@@ -101,6 +126,10 @@ protected function setUp(): void
101
126
return $ datatables ->eloquent (Post::with ('heart ' )->select ('posts.* ' ))->toJson ();
102
127
});
103
128
129
+ $ this ->app ['router ' ]->get ('/relations/hasOneThroughSearchRelation ' , function (DataTables $ datatables ) {
130
+ return $ datatables ->eloquent (Post::with ('heart ' ))->addColumns (['hearts.size ' ])->toJson ();
131
+ });
132
+
104
133
$ this ->app ['router ' ]->get ('/relations/hasOneThroughWithTrashed ' , function (DataTables $ datatables ) {
105
134
return $ datatables ->eloquent (Post::with (['heart ' => function ($ query ) {
106
135
$ query ->withTrashed ();
You can’t perform that action at this time.
0 commit comments