Skip to content

Commit

Permalink
Merge pull request #1493 from yajra/analysis-8QjQym
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
yajra authored Nov 2, 2017
2 parents f072165 + 3229145 commit fddf0d7
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/CollectionDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected function globalSearch($keyword)
$data = $this->serialize($row);
foreach ($this->request->searchableColumnIndex() as $index) {
$column = $this->getColumnName($index);
$value = Arr::get($data, $column);
$value = Arr::get($data, $column);
if (! $value || is_array($value)) {
if (! is_numeric($value)) {
continue;
Expand Down
6 changes: 3 additions & 3 deletions src/QueryDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ protected function regexColumnSearch($column, $keyword)
break;

default:
$sql = ! $this->config->isCaseInsensitive()
$sql = ! $this->config->isCaseInsensitive()
? $column . ' REGEXP ?'
: 'LOWER(' . $column . ') REGEXP ?';
$keyword = Str::lower($keyword);
Expand Down Expand Up @@ -582,8 +582,8 @@ protected function defaultOrdering()
$this->applyOrderColumn($column, $orderable);
} else {
$nullsLastSql = $this->getNullsLastSql($column, $orderable['direction']);
$normalSql = $this->wrap($column) . ' ' . $orderable['direction'];
$sql = $this->nullsLast ? $nullsLastSql : $normalSql;
$normalSql = $this->wrap($column) . ' ' . $orderable['direction'];
$sql = $this->nullsLast ? $nullsLastSql : $normalSql;
$this->query->orderByRaw($sql);
}
});
Expand Down
26 changes: 13 additions & 13 deletions src/config/datatables.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
/*
* DataTables search options.
*/
'search' => [
'search' => [
/*
* Smart search will enclose search keyword with wildcard string "%keyword%".
* SQL: column LIKE "%keyword%"
*/
'smart' => true,
'smart' => true,

/*
* Multi-term search will explode search keyword using spaces resulting into multiple term search.
*/
'multi_term' => true,
'multi_term' => true,

/*
* Case insensitive will search the keyword in lower case format.
Expand All @@ -26,19 +26,19 @@
* Wild card will add "%" in between every characters of the keyword.
* SQL: column LIKE "%k%e%y%w%o%r%d%"
*/
'use_wildcards' => false,
'use_wildcards' => false,
],

/*
* DataTables internal index id response column name.
*/
'index_column' => 'DT_Row_Index',
'index_column' => 'DT_Row_Index',

/*
* List of available builders for DataTables.
* This is where you can register your custom dataTables builder.
*/
'engines' => [
'engines' => [
'eloquent' => \Yajra\DataTables\EloquentDataTable::class,
'query' => \Yajra\DataTables\QueryDataTable::class,
'collection' => \Yajra\DataTables\CollectionDataTable::class,
Expand All @@ -49,7 +49,7 @@
* This is where you can override which engine a builder should use
* Note, only change this if you know what you are doing!
*/
'builders' => [
'builders' => [
//Illuminate\Database\Eloquent\Relations\Relation::class => 'eloquent',
//Illuminate\Database\Eloquent\Builder::class => 'eloquent',
//Illuminate\Database\Query\Builder::class => 'query',
Expand All @@ -69,28 +69,28 @@
* 'throw' - Throws a \Yajra\DataTables\Exceptions\Exception. Use your custom error handler if needed.
* 'custom message' - Any friendly message to be displayed to the user. You can also use translation key.
*/
'error' => env('DATATABLES_ERROR', null),
'error' => env('DATATABLES_ERROR', null),

/*
* Default columns definition of dataTable utility functions.
*/
'columns' => [
'columns' => [
/*
* List of columns hidden/removed on json response.
*/
'excess' => ['rn', 'row_num'],
'excess' => ['rn', 'row_num'],

/*
* List of columns to be escaped. If set to *, all columns are escape.
* Note: You can set the value to empty array to disable XSS protection.
*/
'escape' => '*',
'escape' => '*',

/*
* List of columns that are allowed to display html content.
* Note: Adding columns to list will make us available to XSS attacks.
*/
'raw' => ['action'],
'raw' => ['action'],

/*
* List of columns are are forbidden from being searched/sorted.
Expand All @@ -107,7 +107,7 @@
/*
* JsonResponse header and options config.
*/
'json' => [
'json' => [
'header' => [],
'options' => 0,
],
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/BelongsToManyRelationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function getJsonResponse(array $params = [])
public function it_can_sort_using_the_relation_with_pagination()
{
$response = $this->getJsonResponse([
'order' => [
'order' => [
[
'column' => 2,
'dir' => 'desc',
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/BelongsToRelationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function getJsonResponse(array $params = [])
public function it_can_sort_using_the_relation_with_pagination()
{
$response = $this->getJsonResponse([
'order' => [
'order' => [
[
'column' => 1,
'dir' => 'desc',
Expand Down
20 changes: 10 additions & 10 deletions tests/Integration/CollectionEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function it_can_perform_global_search()
['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'],
['data' => 'email', 'name' => 'email', 'searchable' => 'true', 'orderable' => 'true'],
],
'search' => ['value' => 'Record 19'],
'search' => ['value' => 'Record 19'],
]);

$crawler->assertJson([
Expand Down Expand Up @@ -96,10 +96,10 @@ public function it_can_sort_case_insensitive_strings()
'columns' => [
['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'],
],
'order' => [['column' => 0, 'dir' => 'asc']],
'start' => 0,
'length' => 10,
'draw' => 1,
'order' => [['column' => 0, 'dir' => 'asc']],
'start' => 0,
'length' => 10,
'draw' => 1,
]);

$collection = collect([
Expand Down Expand Up @@ -148,13 +148,13 @@ public function it_can_search_on_added_columns()
['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'],
['data' => 'foo', 'name' => 'foo', 'searchable' => 'true', 'orderable' => 'true'],
],
'order' => [['column' => 0, 'dir' => 'asc']],
'start' => 0,
'search' => [
'order' => [['column' => 0, 'dir' => 'asc']],
'start' => 0,
'search' => [
'value' => 'bar aaa',
],
'length' => 10,
'draw' => 1,
'length' => 10,
'draw' => 1,
]);

$collection = collect([
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/EloquentEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function it_can_perform_global_search()
['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'],
['data' => 'email', 'name' => 'email', 'searchable' => 'true', 'orderable' => 'true'],
],
'search' => ['value' => 'Record-19'],
'search' => ['value' => 'Record-19'],
]);

$crawler->assertJson([
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/EloquentJoinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function getJsonResponse(array $params = [])
public function it_can_sort_using_the_relation_with_pagination()
{
$response = $this->getJsonResponse([
'order' => [
'order' => [
[
'column' => 1,
'dir' => 'desc',
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/HasOneRelationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function getJsonResponse(array $params = [])
public function it_can_sort_using_the_relation_with_pagination()
{
$response = $this->getJsonResponse([
'order' => [
'order' => [
[
'column' => 0,
'dir' => 'desc',
Expand Down
10 changes: 5 additions & 5 deletions tests/Integration/QueryEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function it_can_perform_global_search()
['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'],
['data' => 'email', 'name' => 'email', 'searchable' => 'true', 'orderable' => 'true'],
],
'search' => ['value' => 'Record-19'],
'search' => ['value' => 'Record-19'],
]);

$crawler->assertJson([
Expand All @@ -52,7 +52,7 @@ public function it_can_perform_multiple_term_global_search()
['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'],
['data' => 'email', 'name' => 'email', 'searchable' => 'true', 'orderable' => 'true'],
],
'search' => ['value' => 'Record-19 Email-19'],
'search' => ['value' => 'Record-19 Email-19'],
]);

$crawler->assertJson([
Expand Down Expand Up @@ -125,7 +125,7 @@ public function it_does_not_allow_search_on_added_columns()
['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'],
['data' => 'email', 'name' => 'email', 'searchable' => 'true', 'orderable' => 'true'],
],
'search' => ['value' => 'Record-19'],
'search' => ['value' => 'Record-19'],
]);

$crawler->assertJson([
Expand All @@ -144,7 +144,7 @@ public function it_can_return_auto_index_column()
['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'],
['data' => 'email', 'name' => 'email', 'searchable' => 'true', 'orderable' => 'true'],
],
'search' => ['value' => 'Record-19'],
'search' => ['value' => 'Record-19'],
]);

$crawler->assertJson([
Expand All @@ -165,7 +165,7 @@ public function it_allows_search_on_added_column_with_custom_filter_handler()
['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'],
['data' => 'email', 'name' => 'email', 'searchable' => 'true', 'orderable' => 'true'],
],
'search' => ['value' => 'Record-19'],
'search' => ['value' => 'Record-19'],
]);

$crawler->assertJson([
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/HelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function test_compile_blade()

public function test_get_mixed_value()
{
$data = [
$data = [
'id' => 1,
'name' => 'John',
'created_at' => '1234',
Expand Down Expand Up @@ -182,9 +182,9 @@ public function test_convert_to_array()

$result = Helper::convertToArray($row);
$expected = [
'id' => 1,
'name' => 'John',
'posts' => [
'id' => 1,
'name' => 'John',
'posts' => [
'id' => 1,
'title' => 'Demo',
],
Expand All @@ -197,7 +197,7 @@ public function test_convert_to_array()

public function test_transform()
{
$data = [
$data = [
[
'id' => 1,
'author' => 'John',
Expand Down
24 changes: 12 additions & 12 deletions tests/Unit/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ public function test_is_searchable()
{
$_GET['search']['value'] = '';
request()->merge($_GET);
$request = $this->getRequest();
$request = $this->getRequest();
$this->assertFalse($request->isSearchable());

$_GET['search']['value'] = 'foo';
request()->merge($_GET);
$request = $this->getRequest();
$request = $this->getRequest();
$this->assertTrue($request->isSearchable());

$_GET['search']['value'] = '0';
request()->merge($_GET);
$request = $this->getRequest();
$request = $this->getRequest();
$this->assertTrue($request->isSearchable());
}

Expand All @@ -40,7 +40,7 @@ public function test_column_keyword()
];

request()->merge($_GET);
$request = $this->getRequest();
$request = $this->getRequest();
$this->assertEquals('foo', $request->columnKeyword(0));
$this->assertEquals('bar', $request->columnKeyword(1));
}
Expand All @@ -54,13 +54,13 @@ public function test_orderable_columns()
'value' => 'foo',
],
];
$_GET['order'] = [];
$_GET['order'][] = [
$_GET['order'] = [];
$_GET['order'][] = [
'column' => 0,
'dir' => 'bar',
];
request()->merge($_GET);
$request = $this->getRequest();
$request = $this->getRequest();
$this->assertEquals([
['column' => 0, 'direction' => 'bar'],
], $request->orderableColumns());
Expand All @@ -75,7 +75,7 @@ public function test_searchable_column_index()
$_GET['columns'][] = ['name' => 'foo', 'searchable' => 'true', 'search' => ['value' => 'foo']];
$_GET['columns'][] = ['name' => 'bar', 'searchable' => 'false', 'search' => ['value' => 'foo']];
request()->merge($_GET);
$request = $this->getRequest();
$request = $this->getRequest();
$this->assertEquals([0], $request->searchableColumnIndex());

$this->assertTrue($request->isColumnSearchable(0, false));
Expand All @@ -93,7 +93,7 @@ public function test_keyword()
$_GET['search'] = [];
$_GET['search'] = ['value' => 'foo'];
request()->merge($_GET);
$request = $this->getRequest();
$request = $this->getRequest();
$this->assertEquals('foo', $request->keyword());
}

Expand All @@ -102,19 +102,19 @@ public function test_is_paginationable()
$_GET['start'] = 1;
$_GET['length'] = 10;
request()->merge($_GET);
$request = $this->getRequest();
$request = $this->getRequest();
$this->assertTrue($request->isPaginationable());

$_GET['start'] = 1;
$_GET['length'] = -1;
request()->merge($_GET);
$request = $this->getRequest();
$request = $this->getRequest();
$this->assertFalse($request->isPaginationable());

$_GET['start'] = null;
$_GET['length'] = 1;
request()->merge($_GET);
$request = $this->getRequest();
$request = $this->getRequest();
$this->assertFalse($request->isPaginationable());
}

Expand Down

0 comments on commit fddf0d7

Please sign in to comment.