Skip to content
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
29 changes: 4 additions & 25 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,9 @@ on:

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.2, 8.1]
laravel: [10.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
carbon: ^2.63
runs-on: ubuntu-latest

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
name: Tests

steps:
- name: Checkout code
Expand All @@ -30,22 +19,12 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: List Installed Dependencies
run: composer show -D
run: composer install --prefer-dist --no-interaction

- name: Execute tests
run: vendor/bin/pest --ci
17 changes: 9 additions & 8 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Livewire\Attributes\Computed;
use Livewire\Attributes\On;
use Livewire\Component;

/**
Expand Down Expand Up @@ -60,14 +62,11 @@ abstract class QueryBuilder extends Component

public array $rowOptions = [10, 25, 50];

protected $listeners = [
'refreshTable' => '$refresh',
];

// protected array $queryString = ['perPage'];

abstract public function query(): Builder;

#[On('refreshTable')]
public function refreshTable(): void {}

public function booted(): void
{
$this->config();
Expand Down Expand Up @@ -98,7 +97,8 @@ public function showQueryBuilder(): bool
return $this->enableQueryBuilder && count($this->conditions());
}

public function getRowsQueryProperty()
#[Computed]
public function rowsQuery()
{
/* @phpstan-ignore-next-line */
$query = $this
Expand Down Expand Up @@ -135,7 +135,8 @@ public function getRowsQueryProperty()
return $query;
}

public function getRowsProperty()
#[Computed]
public function rows()
{
// return $this->cache(function () {
return $this->applyPagination($this->rowsQuery); /* @phpstan-ignore-line */
Expand Down
15 changes: 9 additions & 6 deletions src/TableBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Livewire\Attributes\Computed;
use Livewire\Attributes\On;
use Livewire\Component;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
Expand All @@ -50,12 +52,11 @@ abstract class TableBuilder extends Component

public array $rowOptions = [10, 25, 50];

protected $listeners = [
'refreshTable' => '$refresh',
];

abstract public function query(): Builder;

#[On('refreshTable')]
public function refreshTable(): void {}

protected function queryString(): array
{
return [
Expand All @@ -78,7 +79,8 @@ public function config(): void
//
}

public function getRowsQueryProperty()
#[Computed]
public function rowsQuery()
{
$query = $this->query()->when($this->sortBy !== '', function ($query) {
if (Str::contains($this->sortBy, '.')) {
Expand Down Expand Up @@ -183,7 +185,8 @@ public function getRowsQueryProperty()
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getRowsProperty()
#[Computed]
public function rows()
{
return $this->applyPagination($this->rowsQuery); /* @phpstan-ignore-line */
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ArchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

it('will not use debugging functions')
->expect(['dd', 'dump', 'ray'])
->each->not->toBeUsed();
->each->not->toBeUsedIn('ACTTraining\QueryBuilder');