Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First release v1.0.0 #12

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Laravel Spatie Filters
# Laravel Datatable API

[![Latest Version on Packagist](https://img.shields.io/packagist/v/teamq-ec/teamq-laravel-spatie-filters.svg?style=flat-square)](https://packagist.org/packages/teamq-ec/teamq-laravel-spatie-filters)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/teamq-ec/teamq-laravel-spatie-filters/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/teamq-ec/teamq-laravel-spatie-filters/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/teamq-ec/teamq-laravel-spatie-filters/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/teamq-ec/teamq-laravel-spatie-filters/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/teamq-ec/teamq-laravel-spatie-filters.svg?style=flat-square)](https://packagist.org/packages/teamq-ec/teamq-laravel-spatie-filters)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/teamq-ec/teamq-laravel-datatables-api.svg?style=flat-square)](https://packagist.org/packages/teamq-ec/teamq-laravel-datatables-api)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/teamq-ec/teamq-laravel-datatables-api/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/teamq-ec/teamq-laravel-datatables-api/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/teamq-ec/teamq-laravel-datatables-api/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/teamq-ec/teamq-laravel-datatables-api/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/teamq-ec/teamq-laravel-datatables-api.svg?style=flat-square)](https://packagist.org/packages/teamq-ec/teamq-laravel-datatables-api)

This is a collection of classes for filters and sorts, extending from the [spatie/laravel-query-builder](https://github.com/spatie/laravel-query-builder) package,
in addition to providing the possibility of applying these filters and sorting in related models using join through
Expand All @@ -20,7 +20,7 @@ composer require teamq/laravel-spatie-filters
You can publish the config file with:

```bash
php artisan vendor:publish --tag="laravel-spatie-filters-config"
php artisan vendor:publish --tag="laravel-datatable-api-config"
```

This is the contents of the published config file:
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "teamq/laravel-spatie-filters",
"name": "teamq/laravel-datatables-api",
"description": "Custom filter and sorting set for 'spatie/laravel-query-builder' package",
"keywords": [
"teamq",
"laravel",
"datatables",
"filters",
"sortings",
"spatie/laravel-query-builder"
],
"homepage": "https://github.com/teamq-ec/teamq-laravel-spatie-filters",
"homepage": "https://github.com/teamq-ec/teamq-laravel-datatables-api",
"license": "MIT",
"authors": [
{
Expand All @@ -31,7 +32,7 @@
},
"autoload": {
"psr-4": {
"TeamQ\\QueryBuilder\\": "src/"
"TeamQ\\Datatables\\": "src/"
}
},
"autoload-dev": {
Expand All @@ -55,7 +56,7 @@
"extra": {
"laravel": {
"providers": [
"TeamQ\\QueryBuilder\\QueryBuilderServiceProvider"
"TeamQ\\Datatables\\DatatablesServiceProvider"
]
}
},
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Concerns/HasPropertyRelationship.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TeamQ\QueryBuilder\Concerns;
namespace TeamQ\Datatables\Concerns;

use Illuminate\Contracts\Database\Query\Expression;
use Illuminate\Database\Eloquent\Builder;
Expand Down
6 changes: 3 additions & 3 deletions src/Concerns/PerPageQuery.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TeamQ\QueryBuilder\Concerns;
namespace TeamQ\Datatables\Concerns;

use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Collection;
Expand Down Expand Up @@ -32,7 +32,7 @@ trait PerPageQuery
*/
public function result($perPage = null, array $columns = ['*'], string $pageName = 'page', $page = null): Collection|array|LengthAwarePaginator
{
$paramName = config('query-builder.parameters.per_page', 'per_page');
$paramName = config('datatables.parameters.per_page', 'per_page');

if ($this->isPerPageAll($paramName)) {
return $this->get($columns);
Expand Down Expand Up @@ -108,6 +108,6 @@ protected function isPerPageAll(string $paramName): bool
{
return
$this->maxPerPage === null &&
$this->request->query($paramName) === config('teamq-query-builder.per_page.all');
$this->request->query($paramName) === config('datatables.per_page.all');
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace TeamQ\QueryBuilder;
namespace TeamQ\Datatables;

use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class QueryBuilderServiceProvider extends PackageServiceProvider
class DatatablesServiceProvider extends PackageServiceProvider
{
public function configurePackage(Package $package): void
{
Expand All @@ -15,7 +15,7 @@ public function configurePackage(Package $package): void
* More info: https://github.com/spatie/laravel-package-tools
*/
$package
->name('teamq-query-builder')
->hasConfigFile();
->name('laravel-datatables-api')
->hasConfigFile('datatables');
}
}
2 changes: 1 addition & 1 deletion src/Enums/AggregationType.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TeamQ\QueryBuilder\Enums;
namespace TeamQ\Datatables\Enums;

/**
* Enum aggregation type.
Expand Down
2 changes: 1 addition & 1 deletion src/Enums/Comparators/Number.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TeamQ\QueryBuilder\Enums\Comparators;
namespace TeamQ\Datatables\Enums\Comparators;

/**
* Number comparison operators.
Expand Down
2 changes: 1 addition & 1 deletion src/Enums/Comparators/Text.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TeamQ\QueryBuilder\Enums\Comparators;
namespace TeamQ\Datatables\Enums\Comparators;

/**
* Text comparison operators.
Expand Down
2 changes: 1 addition & 1 deletion src/Enums/JoinType.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TeamQ\QueryBuilder\Enums;
namespace TeamQ\Datatables\Enums;

/**
* Enum join type.
Expand Down
4 changes: 2 additions & 2 deletions src/Filters/DateFilter.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace TeamQ\QueryBuilder\Filters;
namespace TeamQ\Datatables\Filters;

use TeamQ\QueryBuilder\Enums\Comparators;
use TeamQ\Datatables\Enums\Comparators;

/**
* Adds custom filter support for dates with comparison operators.
Expand Down
6 changes: 3 additions & 3 deletions src/Filters/Filter.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace TeamQ\QueryBuilder\Filters;
namespace TeamQ\Datatables\Filters;

use Illuminate\Database\Eloquent\Builder;
use Spatie\QueryBuilder\Filters\Filter as IFilter;
use TeamQ\QueryBuilder\Concerns\HasPropertyRelationship;
use TeamQ\QueryBuilder\Enums\JoinType;
use TeamQ\Datatables\Concerns\HasPropertyRelationship;
use TeamQ\Datatables\Enums\JoinType;

/**
* Filter Base Class.
Expand Down
6 changes: 3 additions & 3 deletions src/Filters/GlobalFilter.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace TeamQ\QueryBuilder\Filters;
namespace TeamQ\Datatables\Filters;

use Illuminate\Contracts\Database\Query\Expression;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Spatie\QueryBuilder\AllowedFilter;
use Spatie\QueryBuilder\Filters\Filter;
use TeamQ\QueryBuilder\Concerns\HasPropertyRelationship;
use TeamQ\QueryBuilder\Enums\JoinType;
use TeamQ\Datatables\Concerns\HasPropertyRelationship;
use TeamQ\Datatables\Enums\JoinType;

/**
* Adds global filter support through the `spatie/laravel-query-builder` package.
Expand Down
4 changes: 2 additions & 2 deletions src/Filters/NumberFilter.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace TeamQ\QueryBuilder\Filters;
namespace TeamQ\Datatables\Filters;

use TeamQ\QueryBuilder\Enums\Comparators;
use TeamQ\Datatables\Enums\Comparators;

/**
* Adds custom filter support for numbers with comparison operators.
Expand Down
4 changes: 2 additions & 2 deletions src/Filters/TextFilter.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace TeamQ\QueryBuilder\Filters;
namespace TeamQ\Datatables\Filters;

use TeamQ\QueryBuilder\Enums\Comparators;
use TeamQ\Datatables\Enums\Comparators;

/**
* Adds custom filter support for text with comparison operators.
Expand Down
4 changes: 2 additions & 2 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace TeamQ\QueryBuilder;
namespace TeamQ\Datatables;

use Spatie\QueryBuilder\QueryBuilder as BaseQueryBuilder;
use TeamQ\QueryBuilder\Concerns\PerPageQuery;
use TeamQ\Datatables\Concerns\PerPageQuery;

/**
* Overwrite the query builder base class and add support for the perPage parameter
Expand Down
8 changes: 4 additions & 4 deletions src/Sorts/CaseSort.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace TeamQ\QueryBuilder\Sorts;
namespace TeamQ\Datatables\Sorts;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Expression;
use Spatie\QueryBuilder\Sorts\Sort;
use TeamQ\QueryBuilder\Concerns\HasPropertyRelationship;
use TeamQ\QueryBuilder\Enums\AggregationType;
use TeamQ\QueryBuilder\Enums\JoinType;
use TeamQ\Datatables\Concerns\HasPropertyRelationship;
use TeamQ\Datatables\Enums\AggregationType;
use TeamQ\Datatables\Enums\JoinType;

/**
* Add support for sorting using select case, for cases such as Enums, States, Constants,
Expand Down
8 changes: 4 additions & 4 deletions src/Sorts/RelationSort.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace TeamQ\QueryBuilder\Sorts;
namespace TeamQ\Datatables\Sorts;

use Illuminate\Database\Eloquent\Builder;
use Spatie\QueryBuilder\Sorts\Sort;
use TeamQ\QueryBuilder\Concerns\HasPropertyRelationship;
use TeamQ\QueryBuilder\Enums\AggregationType;
use TeamQ\QueryBuilder\Enums\JoinType;
use TeamQ\Datatables\Concerns\HasPropertyRelationship;
use TeamQ\Datatables\Enums\AggregationType;
use TeamQ\Datatables\Enums\JoinType;

/**
* Adds the possibility to sort by related fields using the kirschbaum-development/eloquent-power-joins.
Expand Down
2 changes: 1 addition & 1 deletion tests/Datasets/Datasets.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use TeamQ\QueryBuilder\Enums\Comparators;
use TeamQ\Datatables\Enums\Comparators;

dataset('per-page-functions', [
'paginate',
Expand Down
6 changes: 3 additions & 3 deletions tests/Filters/DateFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
use Spatie\QueryBuilder\AllowedFilter;
use Spatie\QueryBuilder\QueryBuilder;
use Symfony\Component\HttpFoundation\Request;
use TeamQ\QueryBuilder\Enums\Comparators;
use TeamQ\QueryBuilder\Enums\JoinType;
use TeamQ\QueryBuilder\Filters\DateFilter;
use TeamQ\Datatables\Enums\Comparators;
use TeamQ\Datatables\Enums\JoinType;
use TeamQ\Datatables\Filters\DateFilter;
use Tests\Mocks\Models\Author;
use Tests\Mocks\Models\Book;
use Tests\Mocks\Models\Chapter;
Expand Down
4 changes: 2 additions & 2 deletions tests/Filters/GlobalFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use Illuminate\Database\Query\Expression;
use Spatie\QueryBuilder\QueryBuilder;
use Symfony\Component\HttpFoundation\Request;
use TeamQ\QueryBuilder\Enums\JoinType;
use TeamQ\QueryBuilder\Filters\GlobalFilter;
use TeamQ\Datatables\Enums\JoinType;
use TeamQ\Datatables\Filters\GlobalFilter;
use Tests\Mocks\Models\Author;
use Tests\Mocks\Models\Book;
use Tests\Mocks\Models\Chapter;
Expand Down
6 changes: 3 additions & 3 deletions tests/Filters/NumberFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
use Spatie\QueryBuilder\AllowedFilter;
use Spatie\QueryBuilder\QueryBuilder;
use Symfony\Component\HttpFoundation\Request;
use TeamQ\QueryBuilder\Enums\Comparators;
use TeamQ\QueryBuilder\Enums\JoinType;
use TeamQ\QueryBuilder\Filters\NumberFilter;
use TeamQ\Datatables\Enums\Comparators;
use TeamQ\Datatables\Enums\JoinType;
use TeamQ\Datatables\Filters\NumberFilter;
use Tests\Mocks\Models\Author;
use Tests\Mocks\Models\Book;
use Tests\Mocks\Models\Chapter;
Expand Down
6 changes: 3 additions & 3 deletions tests/Filters/PowerJoins/TextFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
use Spatie\QueryBuilder\AllowedFilter;
use Spatie\QueryBuilder\QueryBuilder;
use Symfony\Component\HttpFoundation\Request;
use TeamQ\QueryBuilder\Enums\Comparators;
use TeamQ\QueryBuilder\Enums\JoinType;
use TeamQ\QueryBuilder\Filters\TextFilter;
use TeamQ\Datatables\Enums\Comparators;
use TeamQ\Datatables\Enums\JoinType;
use TeamQ\Datatables\Filters\TextFilter;
use Tests\Mocks\Models\Country;
use Tests\Mocks\Models\Flight;

Expand Down
6 changes: 3 additions & 3 deletions tests/Filters/TextFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
use Spatie\QueryBuilder\AllowedFilter;
use Spatie\QueryBuilder\QueryBuilder;
use Symfony\Component\HttpFoundation\Request;
use TeamQ\QueryBuilder\Enums\Comparators;
use TeamQ\QueryBuilder\Enums\JoinType;
use TeamQ\QueryBuilder\Filters\TextFilter;
use TeamQ\Datatables\Enums\Comparators;
use TeamQ\Datatables\Enums\JoinType;
use TeamQ\Datatables\Filters\TextFilter;
use Tests\Mocks\Models\Author;
use Tests\Mocks\Models\Book;
use Tests\Mocks\Models\Chapter;
Expand Down
2 changes: 1 addition & 1 deletion tests/Queries/PerPageQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Symfony\Component\HttpFoundation\Request;
use TeamQ\QueryBuilder\QueryBuilder;
use TeamQ\Datatables\QueryBuilder;
use Tests\Mocks\Models\Author;

beforeEach(function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/Sorts/CaseSortTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Spatie\QueryBuilder\AllowedSort;
use Spatie\QueryBuilder\QueryBuilder;
use Symfony\Component\HttpFoundation\Request;
use TeamQ\QueryBuilder\Sorts\CaseSort;
use TeamQ\Datatables\Sorts\CaseSort;
use Tests\Mocks\Enums\AuthorTypeEnum;
use Tests\Mocks\Enums\BookClassificationEnum;
use Tests\Mocks\Models\Author;
Expand Down
4 changes: 2 additions & 2 deletions tests/Sorts/PowerJoins/RelationSortTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use Spatie\QueryBuilder\AllowedSort;
use Spatie\QueryBuilder\QueryBuilder;
use Symfony\Component\HttpFoundation\Request;
use TeamQ\QueryBuilder\Enums\JoinType;
use TeamQ\QueryBuilder\Sorts\RelationSort;
use TeamQ\Datatables\Enums\JoinType;
use TeamQ\Datatables\Sorts\RelationSort;
use Tests\Mocks\Models\Country;
use Tests\Mocks\Models\Flight;

Expand Down
6 changes: 3 additions & 3 deletions tests/Sorts/RelationSortTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
use Spatie\QueryBuilder\AllowedSort;
use Spatie\QueryBuilder\QueryBuilder;
use Symfony\Component\HttpFoundation\Request;
use TeamQ\QueryBuilder\Enums\AggregationType;
use TeamQ\QueryBuilder\Enums\JoinType;
use TeamQ\QueryBuilder\Sorts\RelationSort;
use TeamQ\Datatables\Enums\AggregationType;
use TeamQ\Datatables\Enums\JoinType;
use TeamQ\Datatables\Sorts\RelationSort;
use Tests\Mocks\Enums\BookClassificationEnum;
use Tests\Mocks\Models\Author;
use Tests\Mocks\Models\Book;
Expand Down
5 changes: 3 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use Kirschbaum\PowerJoins\PowerJoinsServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;
use TeamQ\QueryBuilder\QueryBuilderServiceProvider;
use Spatie\QueryBuilder\QueryBuilderServiceProvider;
use TeamQ\Datatables\DatatablesServiceProvider;

class TestCase extends Orchestra
{
Expand All @@ -18,8 +19,8 @@ protected function setUp(): void
protected function getPackageProviders($app): array
{
return [
\Spatie\QueryBuilder\QueryBuilderServiceProvider::class,
QueryBuilderServiceProvider::class,
DatatablesServiceProvider::class,
PowerJoinsServiceProvider::class,
];
}
Expand Down
Loading