Skip to content

Commit 45dbcfd

Browse files
authored
Merge pull request #3108 from yajra/analysis-b06GGa
Apply fixes from StyleCI
2 parents d110a78 + 33429b0 commit 45dbcfd

17 files changed

+202
-202
lines changed

src/DataTableAbstract.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ abstract class DataTableAbstract implements DataTable
103103
* @var array
104104
*/
105105
protected array $templates = [
106-
'DT_RowId' => '',
106+
'DT_RowId' => '',
107107
'DT_RowClass' => '',
108-
'DT_RowData' => [],
109-
'DT_RowAttr' => [],
108+
'DT_RowData' => [],
109+
'DT_RowAttr' => [],
110110
];
111111

112112
/**
@@ -920,10 +920,10 @@ protected function processResults($results, $object = false): array
920920
protected function render(array $data): JsonResponse
921921
{
922922
$output = $this->attachAppends([
923-
'draw' => $this->request->draw(),
924-
'recordsTotal' => $this->totalRecords,
923+
'draw' => $this->request->draw(),
924+
'recordsTotal' => $this->totalRecords,
925925
'recordsFiltered' => $this->filteredRecords ?? 0,
926-
'data' => $data,
926+
'data' => $data,
927927
]);
928928

929929
if ($this->config->isDebugging()) {
@@ -987,11 +987,11 @@ protected function errorResponse(\Exception $exception)
987987
$this->getLogger()->error($exception);
988988

989989
return new JsonResponse([
990-
'draw' => $this->request->draw(),
991-
'recordsTotal' => $this->totalRecords,
990+
'draw' => $this->request->draw(),
991+
'recordsTotal' => $this->totalRecords,
992992
'recordsFiltered' => 0,
993-
'data' => [],
994-
'error' => $error ? __($error) : "Exception Message:\n\n".$exception->getMessage(),
993+
'data' => [],
994+
'error' => $error ? __($error) : "Exception Message:\n\n".$exception->getMessage(),
995995
]);
996996
}
997997

src/config/datatables.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
/*
55
* DataTables search options.
66
*/
7-
'search' => [
7+
'search' => [
88
/*
99
* Smart search will enclose search keyword with wildcard string "%keyword%".
1010
* SQL: column LIKE "%keyword%"
1111
*/
12-
'smart' => true,
12+
'smart' => true,
1313

1414
/*
1515
* Multi-term search will explode search keyword using spaces resulting into multiple term search.
1616
*/
17-
'multi_term' => true,
17+
'multi_term' => true,
1818

1919
/*
2020
* Case insensitive will search the keyword in lower case format.
@@ -26,27 +26,27 @@
2626
* Wild card will add "%" in between every characters of the keyword.
2727
* SQL: column LIKE "%k%e%y%w%o%r%d%"
2828
*/
29-
'use_wildcards' => false,
29+
'use_wildcards' => false,
3030

3131
/*
3232
* Perform a search which starts with the given keyword.
3333
* SQL: column LIKE "keyword%"
3434
*/
35-
'starts_with' => false,
35+
'starts_with' => false,
3636
],
3737

3838
/*
3939
* DataTables internal index id response column name.
4040
*/
41-
'index_column' => 'DT_RowIndex',
41+
'index_column' => 'DT_RowIndex',
4242

4343
/*
4444
* List of available builders for DataTables.
4545
* This is where you can register your custom dataTables builder.
4646
*/
47-
'engines' => [
48-
'eloquent' => Yajra\DataTables\EloquentDataTable::class,
49-
'query' => Yajra\DataTables\QueryDataTable::class,
47+
'engines' => [
48+
'eloquent' => Yajra\DataTables\EloquentDataTable::class,
49+
'query' => Yajra\DataTables\QueryDataTable::class,
5050
'collection' => Yajra\DataTables\CollectionDataTable::class,
5151
'resource' => Yajra\DataTables\ApiResourceDataTable::class,
5252
],
@@ -56,7 +56,7 @@
5656
* This is where you can override which engine a builder should use
5757
* Note, only change this if you know what you are doing!
5858
*/
59-
'builders' => [
59+
'builders' => [
6060
//Illuminate\Database\Eloquent\Relations\Relation::class => 'eloquent',
6161
//Illuminate\Database\Eloquent\Builder::class => 'eloquent',
6262
//Illuminate\Database\Query\Builder::class => 'query',
@@ -76,28 +76,28 @@
7676
* 'throw' - Throws a \Yajra\DataTables\Exceptions\Exception. Use your custom error handler if needed.
7777
* 'custom message' - Any friendly message to be displayed to the user. You can also use translation key.
7878
*/
79-
'error' => env('DATATABLES_ERROR', null),
79+
'error' => env('DATATABLES_ERROR', null),
8080

8181
/*
8282
* Default columns definition of dataTable utility functions.
8383
*/
84-
'columns' => [
84+
'columns' => [
8585
/*
8686
* List of columns hidden/removed on json response.
8787
*/
88-
'excess' => ['rn', 'row_num'],
88+
'excess' => ['rn', 'row_num'],
8989

9090
/*
9191
* List of columns to be escaped. If set to *, all columns are escape.
9292
* Note: You can set the value to empty array to disable XSS protection.
9393
*/
94-
'escape' => '*',
94+
'escape' => '*',
9595

9696
/*
9797
* List of columns that are allowed to display html content.
9898
* Note: Adding columns to list will make us available to XSS attacks.
9999
*/
100-
'raw' => ['action'],
100+
'raw' => ['action'],
101101

102102
/*
103103
* List of columns are forbidden from being searched/sorted.
@@ -114,8 +114,8 @@
114114
/*
115115
* JsonResponse header and options config.
116116
*/
117-
'json' => [
118-
'header' => [],
117+
'json' => [
118+
'header' => [],
119119
'options' => 0,
120120
],
121121

tests/Http/Resources/UserResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function toArray($request)
1818
return [
1919
// 'id' => $this->id,
2020
'email' => $this->email,
21-
'name' => $this->name,
21+
'name' => $this->name,
2222
];
2323
}
2424
}

tests/Integration/BelongsToManyRelationTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public function it_returns_all_records_with_the_relation_when_called_without_par
1616
{
1717
$response = $this->call('GET', '/relations/belongsToMany');
1818
$response->assertJson([
19-
'draw' => 0,
20-
'recordsTotal' => 20,
19+
'draw' => 0,
20+
'recordsTotal' => 20,
2121
'recordsFiltered' => 20,
2222
]);
2323

@@ -33,8 +33,8 @@ public function it_can_perform_global_search_on_the_relation()
3333
]);
3434

3535
$response->assertJson([
36-
'draw' => 0,
37-
'recordsTotal' => 20,
36+
'draw' => 0,
37+
'recordsTotal' => 20,
3838
'recordsFiltered' => 10,
3939
]);
4040

@@ -61,17 +61,17 @@ public function it_can_sort_using_the_relation_with_pagination()
6161
'order' => [
6262
[
6363
'column' => 2,
64-
'dir' => 'desc',
64+
'dir' => 'desc',
6565
],
6666
],
6767
'length' => 10,
68-
'start' => 0,
69-
'draw' => 1,
68+
'start' => 0,
69+
'draw' => 1,
7070
]);
7171

7272
$response->assertJson([
73-
'draw' => 1,
74-
'recordsTotal' => 20,
73+
'draw' => 1,
74+
'recordsTotal' => 20,
7575
'recordsFiltered' => 20,
7676
]);
7777

tests/Integration/BelongsToRelationTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public function it_returns_all_records_with_the_relation_when_called_without_par
1616
{
1717
$response = $this->call('GET', '/relations/belongsTo');
1818
$response->assertJson([
19-
'draw' => 0,
20-
'recordsTotal' => 60,
19+
'draw' => 0,
20+
'recordsTotal' => 60,
2121
'recordsFiltered' => 60,
2222
]);
2323

@@ -33,8 +33,8 @@ public function it_can_perform_global_search_on_the_relation()
3333
]);
3434

3535
$response->assertJson([
36-
'draw' => 0,
37-
'recordsTotal' => 60,
36+
'draw' => 0,
37+
'recordsTotal' => 60,
3838
'recordsFiltered' => 3,
3939
]);
4040

@@ -61,17 +61,17 @@ public function it_can_sort_using_the_relation_with_pagination()
6161
'order' => [
6262
[
6363
'column' => 1,
64-
'dir' => 'desc',
64+
'dir' => 'desc',
6565
],
6666
],
6767
'length' => 10,
68-
'start' => 0,
69-
'draw' => 1,
68+
'start' => 0,
69+
'draw' => 1,
7070
]);
7171

7272
$response->assertJson([
73-
'draw' => 1,
74-
'recordsTotal' => 60,
73+
'draw' => 1,
74+
'recordsTotal' => 60,
7575
'recordsFiltered' => 60,
7676
]);
7777

tests/Integration/CollectionDataTableTest.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public function it_returns_all_records_when_no_parameters_is_passed()
1919
{
2020
$crawler = $this->call('GET', '/collection/users');
2121
$crawler->assertJson([
22-
'draw' => 0,
23-
'recordsTotal' => 20,
22+
'draw' => 0,
23+
'recordsTotal' => 20,
2424
'recordsFiltered' => 20,
2525
]);
2626
}
@@ -33,7 +33,7 @@ public function it_returns_zero_filtered_records_on_empty_collection()
3333
'data' => [],
3434
'draw' => 0,
3535
'input' => [],
36-
'recordsTotal' => 0,
36+
'recordsTotal' => 0,
3737
'recordsFiltered' => 0,
3838
]);
3939
}
@@ -50,8 +50,8 @@ public function it_can_perform_global_search()
5050
]);
5151

5252
$crawler->assertJson([
53-
'draw' => 0,
54-
'recordsTotal' => 20,
53+
'draw' => 0,
54+
'recordsTotal' => 20,
5555
'recordsFiltered' => 1,
5656
]);
5757
}
@@ -109,10 +109,10 @@ public function it_can_sort_case_insensitive_strings()
109109
'columns' => [
110110
['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'],
111111
],
112-
'order' => [['column' => 0, 'dir' => 'asc']],
113-
'start' => 0,
112+
'order' => [['column' => 0, 'dir' => 'asc']],
113+
'start' => 0,
114114
'length' => 10,
115-
'draw' => 1,
115+
'draw' => 1,
116116
]);
117117

118118
$collection = collect([
@@ -129,10 +129,10 @@ public function it_can_sort_case_insensitive_strings()
129129
$response = $dataTable->toJson();
130130

131131
$this->assertEquals([
132-
'draw' => 1,
133-
'recordsTotal' => 6,
132+
'draw' => 1,
133+
'recordsTotal' => 6,
134134
'recordsFiltered' => 6,
135-
'data' => [
135+
'data' => [
136136
['name' => 'aaa'],
137137
['name' => 'ABC'],
138138
['name' => 'bbb'],
@@ -151,10 +151,10 @@ public function it_can_sort_numeric_strings()
151151
'columns' => [
152152
['data' => 'amount', 'name' => 'amount', 'searchable' => 'true', 'orderable' => 'true'],
153153
],
154-
'order' => [['column' => 0, 'dir' => 'asc']],
155-
'start' => 0,
154+
'order' => [['column' => 0, 'dir' => 'asc']],
155+
'start' => 0,
156156
'length' => 10,
157-
'draw' => 1,
157+
'draw' => 1,
158158
]);
159159

160160
$collection = collect([
@@ -171,10 +171,10 @@ public function it_can_sort_numeric_strings()
171171
$response = $dataTable->toJson();
172172

173173
$this->assertEquals([
174-
'draw' => 1,
175-
'recordsTotal' => 6,
174+
'draw' => 1,
175+
'recordsTotal' => 6,
176176
'recordsFiltered' => 6,
177-
'data' => [
177+
'data' => [
178178
['amount' => '-8'],
179179
['amount' => '-3'],
180180
['amount' => '0'],
@@ -203,13 +203,13 @@ public function it_can_search_on_added_columns()
203203
['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'],
204204
['data' => 'foo', 'name' => 'foo', 'searchable' => 'true', 'orderable' => 'true'],
205205
],
206-
'order' => [['column' => 0, 'dir' => 'asc']],
207-
'start' => 0,
206+
'order' => [['column' => 0, 'dir' => 'asc']],
207+
'start' => 0,
208208
'search' => [
209209
'value' => 'bar aaa',
210210
],
211211
'length' => 10,
212-
'draw' => 1,
212+
'draw' => 1,
213213
]);
214214

215215
$collection = collect([
@@ -226,10 +226,10 @@ public function it_can_search_on_added_columns()
226226
$response = $dataTable->addColumn('foo', 'bar {{$name}}')->toJson();
227227

228228
$this->assertEquals([
229-
'draw' => 1,
230-
'recordsTotal' => 6,
229+
'draw' => 1,
230+
'recordsTotal' => 6,
231231
'recordsFiltered' => 1,
232-
'data' => [
232+
'data' => [
233233
['name' => 'aaa', 'foo' => 'bar aaa'],
234234
],
235235
], $response->getData(true));

tests/Integration/CustomOrderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function it_can_order_with_custom_order()
1818
'order' => [
1919
[
2020
'column' => 0,
21-
'dir' => 'asc',
21+
'dir' => 'asc',
2222
],
2323
],
2424
]);
@@ -36,9 +36,9 @@ protected function getJsonResponse(array $params = [])
3636
['data' => 'user.id', 'name' => 'user.id', 'searchable' => 'true', 'orderable' => 'true'],
3737
['data' => 'title', 'name' => 'posts.title', 'searchable' => 'true', 'orderable' => 'true'],
3838
],
39-
'length' => 10,
40-
'start' => 0,
41-
'draw' => 1,
39+
'length' => 10,
40+
'start' => 0,
41+
'draw' => 1,
4242
];
4343

4444
return $this->call(

0 commit comments

Comments
 (0)