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
539539 */
540540 public function setTotalRecords (int $ total ): static
541541 {
542- $ this ->skipTotalRecords ();
543542 $ this ->totalRecords = $ total ;
544543
545544 return $ this ;
Original file line number Diff line number Diff line change @@ -116,11 +116,9 @@ protected function prepareQuery(): static
116116 if (! $ this ->prepared ) {
117117 $ this ->totalRecords = $ this ->totalCount ();
118118
119- if ($ this ->totalRecords ) {
120- $ this ->filterRecords ();
121- $ this ->ordering ();
122- $ this ->paginate ();
123- }
119+ $ this ->filterRecords ();
120+ $ this ->ordering ();
121+ $ this ->paginate ();
124122 }
125123
126124 $ this ->prepared = true ;
Original file line number Diff line number Diff line change @@ -29,6 +29,17 @@ public function it_can_set_total_records()
2929 ]);
3030 }
3131
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+
3243 /** @test */
3344 public function it_can_set_total_filtered_records ()
3445 {
@@ -83,7 +94,7 @@ public function it_can_skip_total_records_count_query()
8394 $ crawler ->assertJson ([
8495 'draw ' => 0 ,
8596 'recordsTotal ' => 0 ,
86- 'recordsFiltered ' => 0 ,
97+ 'recordsFiltered ' => 1 ,
8798 ]);
8899 }
89100
@@ -429,6 +440,12 @@ protected function setUp(): void
429440 ->toJson ();
430441 });
431442
443+ $ router ->get ('/zero-total-records ' , function (DataTables $ dataTable ) {
444+ return $ dataTable ->query (DB ::table ('users ' ))
445+ ->setTotalRecords (0 )
446+ ->toJson ();
447+ });
448+
432449 $ router ->get ('/set-filtered-records ' , function (DataTables $ dataTable ) {
433450 return $ dataTable ->query (DB ::table ('users ' ))
434451 ->setFilteredRecords (10 )
You can’t perform that action at this time.
0 commit comments