Skip to content

Commit c814b59

Browse files
hamidrezarjgithub-actions[bot]
authored andcommitted
Fix styling
1 parent 161708e commit c814b59

File tree

15 files changed

+58
-86
lines changed

15 files changed

+58
-86
lines changed

database/factories/UserFactory.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use HamidRrj\LaravelDatatable\Tests\Models\User;
66
use Illuminate\Database\Eloquent\Factories\Factory;
77

8-
98
class UserFactory extends Factory
109
{
1110
protected $model = User::class;
@@ -16,17 +15,16 @@ public function definition()
1615
'name' => $this->faker->name(),
1716
'username' => $this->faker->userName(),
1817
'email' => $this->faker->email,
19-
// 'position' => $this->faker->randomElement(['boss']),
20-
// 'city_id' => City::factory(),
21-
// 'province_id' => function (array $attributes) {
22-
// return City::find($attributes['city_id'])->province_id;
23-
// },
24-
// 'city_name' => function (array $attributes) {
25-
// return City::find($attributes['city_id'])->name;
26-
// },
18+
// 'position' => $this->faker->randomElement(['boss']),
19+
// 'city_id' => City::factory(),
20+
// 'province_id' => function (array $attributes) {
21+
// return City::find($attributes['city_id'])->province_id;
22+
// },
23+
// 'city_name' => function (array $attributes) {
24+
// return City::find($attributes['city_id'])->name;
25+
// },
2726

2827
];
2928

3029
}
3130
}
32-

src/DatatableInput.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ public function __construct(
1515
private array $rels,
1616
private array $allowedFilters,
1717
private array $allowedSortings,
18-
) {
19-
}
18+
) {}
2019

2120
public function getStart(): int
2221
{

src/DatatableService.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,63 @@
88

99
class DatatableService
1010
{
11-
1211
protected array $allowedFilters;
12+
1313
protected array $allowedRelations;
14+
1415
protected array $allowedSortings;
16+
1517
protected array $allowedSelects;
18+
1619
private int $totalRowCount;
1720

1821
public function __construct(
19-
protected Builder $query,
22+
protected Builder $query,
2023
private DatatableInput $dataTableInput
21-
)
22-
{
23-
}
24+
) {}
2425

2526
public function setAllowedFilters(array $allowedFilters): DatatableService
2627
{
2728
$this->allowedFilters = $allowedFilters;
29+
2830
return $this;
2931
}
3032

3133
public function setAllowedRelations(array $allowedRelations): DatatableService
3234
{
3335
$this->allowedRelations = $allowedRelations;
36+
3437
return $this;
3538
}
3639

3740
public function setAllowedSortings(array $allowedSortings): DatatableService
3841
{
3942
$this->allowedSortings = $allowedSortings;
43+
4044
return $this;
4145
}
4246

4347
public function setAllowedSelects(array $allowedSelects): DatatableService
4448
{
4549
$this->allowedSelects = $allowedSelects;
50+
4651
return $this;
4752
}
4853

4954
/**
5055
* Handle 'getData' operations
51-
* @return array
5256
*/
5357
public function getData(): array
5458
{
5559
$query = $this->buildQuery();
5660
$data = $query->get()->toArray();
5761

58-
return array(
62+
return [
5963
'data' => $data,
6064
'meta' => [
61-
'totalRowCount' => $this->totalRowCount
62-
]
63-
);
65+
'totalRowCount' => $this->totalRowCount,
66+
],
67+
];
6468
}
6569

6670
protected function buildQuery(): Builder

src/DatatableServiceProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace HamidRrj\LaravelDatatable;
44

5-
use HamidRrj\LaravelDatatable\Commands\LaravelDatatableCommand;
65
use Spatie\LaravelPackageTools\Package;
76
use Spatie\LaravelPackageTools\PackageServiceProvider;
87

src/Exceptions/InvalidParameterInterface.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace HamidRrj\LaravelDatatable\Exceptions;
44

5-
interface InvalidParameterInterface
6-
{
7-
}
5+
interface InvalidParameterInterface {}

src/Facades/Datatable.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,21 @@ class Datatable
1313
{
1414
/**
1515
* Extracts data from request, passes to datatable service and prepares data for response.
16-
* @param Model|Builder $mixed
17-
* @param array $requestParameters
18-
* @param array $allowedFilters
19-
* @param array $allowedRelations
20-
* @param array $allowedSortings
21-
* @param array $allowedSelects
22-
* @return array
16+
*
2317
* @throws InvalidParameterInterface if input parameters are invalid.
2418
*/
2519
public function run(
2620
Model|Builder $mixed,
27-
array $requestParameters,
28-
array $allowedFilters = [],
29-
array $allowedRelations = [],
30-
array $allowedSortings = [],
31-
array $allowedSelects = []
32-
): array
33-
{
21+
array $requestParameters,
22+
array $allowedFilters = [],
23+
array $allowedRelations = [],
24+
array $allowedSortings = [],
25+
array $allowedSelects = []
26+
): array {
3427

3528
$filters = json_decode($requestParameters['filters']);
3629
$sorting = json_decode($requestParameters['sorting']);
37-
$rels = array_key_exists('rels', $requestParameters) ? $requestParameters['rels'] : array();
30+
$rels = array_key_exists('rels', $requestParameters) ? $requestParameters['rels'] : [];
3831

3932
$dataTableInput = new DataTableInput(
4033
$requestParameters['start'],

src/Filter/ApplyFilter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ class ApplyFilter
2020
public function __construct(
2121
private Builder $query,
2222
private Filter $filter,
23-
) {
24-
}
23+
) {}
2524

2625
public function apply(): Builder
2726
{

src/Filter/SearchFunctions/SearchFilter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ abstract class SearchFilter
1010
public function __construct(
1111
protected Builder $query,
1212
protected Filter $filter,
13-
) {
14-
}
13+
) {}
1514

1615
abstract public function apply(): Builder;
1716
}

src/Sort/ApplySort.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ class ApplySort
1212
public function __construct(
1313
private Builder $query,
1414
private ?Sort $sort,
15-
) {
16-
}
15+
) {}
1716

1817
public function apply(): Builder
1918
{

src/Sort/Sort.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,17 @@ class Sort
99
private static SortingValidator $sortingValidator;
1010

1111
/**
12-
* @param string $id
13-
* @param bool $desc
14-
* @param array $allowedSortings
1512
* @throws InvalidSortingException
1613
*/
1714
public function __construct(
1815
private string $id,
19-
private bool $desc,
16+
private bool $desc,
2017
private array $allowedSortings,
21-
)
22-
{
18+
) {
2319
self::$sortingValidator = SortingValidator::getInstance();
2420
self::$sortingValidator->isValid($this, $this->allowedSortings);
2521
}
2622

27-
/**
28-
* @return string
29-
*/
3023
public function getId(): string
3124
{
3225
return $this->id;

0 commit comments

Comments
 (0)