Skip to content

Commit

Permalink
fixed styling | removed unnecessary imports
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidrezarj committed Jul 19, 2024
2 parents 9df2b19 + c814b59 commit 7bb07d3
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 34 deletions.
3 changes: 1 addition & 2 deletions src/DatatableInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public function __construct(
private array $rels,
private array $allowedFilters,
private array $allowedSortings,
) {
}
) {}

public function getStart(): int
{
Expand Down
19 changes: 10 additions & 9 deletions src/DatatableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@

class DatatableService
{

protected array $allowedFilters;

protected array $allowedRelations;

protected array $allowedSortings;

protected array $allowedSelects;

private int $totalRowCount;

public function __construct(
protected Builder $query,
protected Builder $query,
private DatatableInput $dataTableInput
)
{
}
) {}

public function setAllowedFilters(array $allowedFilters): DatatableService
{
Expand Down Expand Up @@ -55,12 +56,12 @@ public function getData(): array
$query = $this->buildQuery();
$data = $query->get()->toArray();

return array(
return [
'data' => $data,
'meta' => [
'totalRowCount' => $this->totalRowCount
]
);
'totalRowCount' => $this->totalRowCount,
],
];
}

protected function buildQuery(): Builder
Expand Down
1 change: 0 additions & 1 deletion src/DatatableServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace HamidRrj\LaravelDatatable;

use HamidRrj\LaravelDatatable\Commands\LaravelDatatableCommand;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

Expand Down
4 changes: 1 addition & 3 deletions src/Exceptions/InvalidParameterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace HamidRrj\LaravelDatatable\Exceptions;

interface InvalidParameterInterface
{
}
interface InvalidParameterInterface {}
3 changes: 1 addition & 2 deletions src/Filter/ApplyFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class ApplyFilter
public function __construct(
private Builder $query,
private Filter $filter,
) {
}
) {}

public function apply(): Builder
{
Expand Down
3 changes: 1 addition & 2 deletions src/Filter/SearchFunctions/SearchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ abstract class SearchFilter
public function __construct(
protected Builder $query,
protected Filter $filter,
) {
}
) {}

abstract public function apply(): Builder;
}
3 changes: 1 addition & 2 deletions src/Sort/ApplySort.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class ApplySort
public function __construct(
private Builder $query,
private ?Sort $sort,
) {
}
) {}

public function apply(): Builder
{
Expand Down
8 changes: 2 additions & 6 deletions src/Sort/Sort.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@ class Sort
*/
public function __construct(

Check failure on line 17 in src/Sort/Sort.php

View workflow job for this annotation

GitHub Actions / phpstan

PHPDoc tag @throws with type HamidRrj\LaravelDatatable\Sort\InvalidSortingException is not subtype of Throwable
private string $id,
private bool $desc,
private bool $desc,
private array $allowedSortings,
)
{
) {
self::$sortingValidator = SortingValidator::getInstance();
self::$sortingValidator->isValid($this, $this->allowedSortings);
}

/**
* @return string
*/
public function getId(): string
{
return $this->id;
Expand Down
4 changes: 1 addition & 3 deletions src/Validators/FilterValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ class FilterValidator
{
private static $instance;

private function __construct()
{
}
private function __construct() {}

public static function getInstance(): FilterValidator
{
Expand Down
4 changes: 1 addition & 3 deletions src/Validators/SortingValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ class SortingValidator
{
private static $instance;

private function __construct()
{
}
private function __construct() {}

public static function getInstance(): SortingValidator
{
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function getEnvironmentSetUp($app)
{
config()->set('database.default', 'testing');


$migration = include __DIR__.'/../database/migrations/create_users_table.php.stub';
$migration->up();

Expand Down

0 comments on commit 7bb07d3

Please sign in to comment.