File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -539,7 +539,6 @@ public function setMultiTerm(bool $multiTerm = true): static
539
539
*/
540
540
public function setTotalRecords (int $ total ): static
541
541
{
542
- $ this ->skipTotalRecords ();
543
542
$ this ->totalRecords = $ total ;
544
543
545
544
return $ this ;
Original file line number Diff line number Diff line change @@ -116,11 +116,9 @@ protected function prepareQuery(): static
116
116
if (! $ this ->prepared ) {
117
117
$ this ->totalRecords = $ this ->totalCount ();
118
118
119
- if ($ this ->totalRecords ) {
120
- $ this ->filterRecords ();
121
- $ this ->ordering ();
122
- $ this ->paginate ();
123
- }
119
+ $ this ->filterRecords ();
120
+ $ this ->ordering ();
121
+ $ this ->paginate ();
124
122
}
125
123
126
124
$ this ->prepared = true ;
Original file line number Diff line number Diff line change @@ -29,6 +29,17 @@ public function it_can_set_total_records()
29
29
]);
30
30
}
31
31
32
+ /** @test */
33
+ public function it_can_set_zero_total_records ()
34
+ {
35
+ $ crawler = $ this ->call ('GET ' , '/zero-total-records ' );
36
+ $ crawler ->assertJson ([
37
+ 'draw ' => 0 ,
38
+ 'recordsTotal ' => 0 ,
39
+ 'recordsFiltered ' => 20 ,
40
+ ]);
41
+ }
42
+
32
43
/** @test */
33
44
public function it_can_set_total_filtered_records ()
34
45
{
@@ -83,7 +94,7 @@ public function it_can_skip_total_records_count_query()
83
94
$ crawler ->assertJson ([
84
95
'draw ' => 0 ,
85
96
'recordsTotal ' => 0 ,
86
- 'recordsFiltered ' => 0 ,
97
+ 'recordsFiltered ' => 1 ,
87
98
]);
88
99
}
89
100
@@ -429,6 +440,12 @@ protected function setUp(): void
429
440
->toJson ();
430
441
});
431
442
443
+ $ router ->get ('/zero-total-records ' , function (DataTables $ dataTable ) {
444
+ return $ dataTable ->query (DB ::table ('users ' ))
445
+ ->setTotalRecords (0 )
446
+ ->toJson ();
447
+ });
448
+
432
449
$ router ->get ('/set-filtered-records ' , function (DataTables $ dataTable ) {
433
450
return $ dataTable ->query (DB ::table ('users ' ))
434
451
->setFilteredRecords (10 )
You can’t perform that action at this time.
0 commit comments