Skip to content

Commit badc59d

Browse files
committed
PHP min version set to 7.1
1 parent 1e1c842 commit badc59d

File tree

6 files changed

+36
-33
lines changed

6 files changed

+36
-33
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Version 0.4.x -
22
----------------------------
33
- Enh: code refactoring in DataGridServiceProvider
44
- Enh: HTML code extracted to view blade files
5+
- Enh: min PHP version is defined as PHP 7.1
56

67

78
Version 0.3.1 - Dec 26, 2020

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This package helps to create DataGrid (CRUD) pages for Laravel 6+ framework appl
88

99
## Requirements
1010

11-
* PHP >=7.0
11+
* PHP >=7.1
1212
* Laravel 6+
1313
* Bootstrap 3+
1414

@@ -65,17 +65,17 @@ Following filter field types are available
6565

6666
Each filter field can include following attributes:
6767

68-
| Attribute | Description |
69-
|------------------|-------------------------------------------------------------------------------|
70-
| `title` | Specifies a title, that will be shown in the label of filter field
71-
| `type` | Specifies a type of the filter field (see above)
72-
| `compareType` | Specifies which type of comparison will be used: ex.: '=', '%like%', '!=' etc.
73-
| `source` | Specifies the source (array) to 'set' fields
74-
| `validation` | Specifies validation rules (array). Possible options: ['minLength'=>2, 'maxLength'=>10, 'min'=>2, 'max'=>100]
75-
| `relation` |
76-
| `relationXref` |
77-
| `htmlOptions` |
78-
| `disabled` |
68+
| Attribute | Type | Description
69+
|------------------|------------|-------------------------------------------------------------------
70+
| `title` | String | Specifies a title, that will be shown in the label of filter field
71+
| `type` | String | Specifies a type of the filter field (see above)
72+
| `compareType` | String | Specifies which type of comparison will be used: ex.: '=', '%like%', '!=' etc.
73+
| `source` | Array | Specifies the source (array) to 'set' fields
74+
| `validation` | Array | Specifies validation rules (array). Possible options: ['minLength'=>2, 'maxLength'=>10, 'min'=>2, 'max'=>100]
75+
| `relation` | String | Specifies the relation between 2 models (One-to-One, One-to-Many), ex.: search in posts for users - relation="posts"
76+
| `relationXref` | String | Specifies the relation between 2 models (Many-to-Many), ex.: search in roles for users - relation="roles"
77+
| `htmlOptions` | Array | Specifies any possible HTML attribute for the field
78+
| `disabled` | Boolean | Specifies whether the field is disabled or not (default - not)
7979

8080

8181
### 3. Handle filters and prepare SQL builder

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}
1414
],
1515
"require": {
16-
"php": ">=7.0.0",
16+
"php": ">=7.1",
1717
"illuminate/support": "~5.0|^6.0",
1818
"jenssegers/agent": "^2.6"
1919
},

src/Apphp/DataGrid/DataGridServiceProvider.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class DataGridServiceProvider extends ServiceProvider
1212
*/
1313
private $dir = '';
1414

15+
/**
16+
* DataGridServiceProvider constructor.
17+
*
18+
* @param $app
19+
*/
1520
public function __construct($app)
1621
{
1722
parent::__construct($app);
@@ -35,8 +40,6 @@ public function boot()
3540
*/
3641
public function register()
3742
{
38-
///$this->app->bind();
39-
4043
$this->app->singleton('filter', function () {
4144
return $this->app->make('Apphp\DataGrid\Filter');
4245
});

src/Apphp/DataGrid/Filter.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Filter
7979
/**
8080
* Filter constructor
8181
*
82-
* @param null $query
82+
* @param Illuminate\Database\Query\Builder $query
8383
* @param Request $request
8484
* @param null $filters
8585
* @param string $submitRoute
@@ -91,11 +91,11 @@ class Filter
9191
public static function init(
9292
$query = null,
9393
Request $request,
94-
$filters = null,
95-
$submitRoute = '',
96-
$cancelRoute = '',
97-
$initMode = '',
98-
$fieldsInRow = 4
94+
array $filters = null,
95+
string $submitRoute = '',
96+
string $cancelRoute = '',
97+
string $initMode = '',
98+
int $fieldsInRow = 4
9999
): Filter
100100
{
101101
self::$debug = true;
@@ -175,7 +175,7 @@ public static function setFilterFields($filterFields): void
175175
* Get filter fields
176176
* @return array
177177
*/
178-
public static function getFilterFields():array
178+
public static function getFilterFields(): array
179179
{
180180
return self::$filterFields;
181181
}
@@ -194,7 +194,7 @@ public static function setSubmitRoute($route = ''): void
194194
* Get submit route
195195
* @return string
196196
*/
197-
public static function getSubmitRoute():string
197+
public static function getSubmitRoute(): string
198198
{
199199
return self::$submitRoute;
200200
}
@@ -223,7 +223,7 @@ public static function setFieldsInRow(int $count = 4): void
223223
* Get cancel route
224224
* @return string
225225
*/
226-
public static function getCancelRoute():string
226+
public static function getCancelRoute(): string
227227
{
228228
return self::$cancelRoute;
229229
}
@@ -233,7 +233,7 @@ public static function getCancelRoute():string
233233
* @param string $mode
234234
* @return void
235235
*/
236-
public static function setMode($mode):void
236+
public static function setMode($mode): void
237237
{
238238
self::$mode = (strtolower($mode) === 'collapsed' ? 'collapsed' : 'opened');
239239
}
@@ -243,7 +243,7 @@ public static function setMode($mode):void
243243
* @param string $query
244244
* @return void
245245
*/
246-
public static function setQuery($query):void
246+
public static function setQuery($query): void
247247
{
248248
self::$query = $query;
249249
}
@@ -424,7 +424,7 @@ public static function filter(): ?Filter
424424
* @param array $filter
425425
* @return void
426426
*/
427-
private static function prepareWhereClause($key, $value, $filter = []): void
427+
private static function prepareWhereClause(string $key, $value, array $filter = []): void
428428
{
429429
$compareType = $filter['compareType'] ?? '=';
430430
$relation = $filter['relation'] ?? null;
@@ -460,7 +460,7 @@ private static function prepareWhereClause($key, $value, $filter = []): void
460460
* @param null|object $query
461461
* @return void
462462
*/
463-
private static function setWhereClause($key, $value, $compareType, $query = null): void
463+
private static function setWhereClause(string $key, $value, string $compareType, array $query = null): void
464464
{
465465
$q = empty($query) ? self::$query : $query;
466466

@@ -552,7 +552,7 @@ public static function renderFields()
552552
// <div class="card-body py-1'.(self::$mode == 'opened' || $filterFields['act'] === 'search' ? '' : ' collapse').'">
553553
// <form action="'.self::getSubmitRoute().'" method="GET">
554554
// <input type="hidden" name="act" value="search">'.PHP_EOL;
555-
555+
556556
$count = 0;
557557
$filterFieldsContent = '<div class="row mb-n2">'.PHP_EOL;
558558
foreach ($filters as $key => $filter) {

src/Apphp/DataGrid/Pagination.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,15 @@ class Pagination
4141
/**
4242
* Pagination constructor
4343
*
44-
* @param null $query
45-
*
44+
* @param Illuminate\Database\Query\Builder $query
4645
* @param int $pageSize
4746
* @param string $sort
4847
* @param string $direction
4948
* @param string $filterFields
5049
*
5150
* @return Pagination
5251
*/
53-
public static function init($query, $pageSize = 20, $sort = '', $direction = '', $filterFields = ''): Pagination
52+
public static function init($query, int $pageSize = 20, string $sort = '', string $direction = '', string $filterFields = ''): Pagination
5453
{
5554
if ( ! empty($query)) {
5655
self::setQuery($query);
@@ -82,7 +81,7 @@ public static function init($query, $pageSize = 20, $sort = '', $direction = '',
8281
* @param string $query
8382
* @return void
8483
*/
85-
public static function setQuery($query): void
84+
public static function setQuery(string $query): void
8685
{
8786
self::$query = $query;
8887
}

0 commit comments

Comments
 (0)