Skip to content

Commit

Permalink
Merge pull request #1591 from rappasoft/develop
Browse files Browse the repository at this point in the history
Pre 3.1.5 release merge
  • Loading branch information
lrljoe authored Dec 9, 2023
2 parents aec86d1 + c06563e commit 2bfe6df
Show file tree
Hide file tree
Showing 61 changed files with 1,312 additions and 191 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/testbench.yaml export-ignore
/codecov.yml export-ignore
/coverage.xml export-ignore
/pint.json export-ignore

# Exclude unminified versions of files
/resources/js/laravel-livewire-tables-thirdparty.js export-ignore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.2]
php: [8.3]
laravel: [10]
stability: [prefer-dist]

Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/run-tests-pcov-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,32 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.2]
php: [8.3]
laravel: [10]
stability: [prefer-dist]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
name: PCOV-PULL - ${{ matrix.os }} - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}
env:
extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }}-withpcov
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pcov,pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: ${{ env.extensionKey }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl, iconv, fileinfo
extensions: ${{ env.extensions }}
tools: phpunit:latest
ini-values: memory_limit=512M
coverage: pcov
Expand All @@ -41,8 +52,8 @@ jobs:
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-
key: ${{ runner.os }}-PCOV-PULL-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-PCOV-PULL-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-

- name: Add token
run: |
Expand Down
30 changes: 24 additions & 6 deletions .github/workflows/run-tests-pcov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,39 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.2]
php: [8.3]
laravel: [10]
stability: [prefer-dist]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
name: PCOV-PUSH - ${{ matrix.os }} - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}
env:
extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }}-withpcov
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pcov,pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr

steps:
- name: Checkout code
uses: actions/checkout@v3


- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: ${{ env.extensionKey }}

- name: Cache extensions
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl, iconv, fileinfo
extensions: ${{ env.extensions }}
tools: phpunit:latest
ini-values: memory_limit=512M
coverage: pcov
Expand All @@ -41,8 +59,8 @@ jobs:
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-
key: ${{ runner.os }}-PCOV-PUSH-PHP-${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-PCOV-PUSH-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-

- name: Add token
run: |
Expand Down
34 changes: 24 additions & 10 deletions .github/workflows/run-tests-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,39 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.1, 8.2]
php: [8.1, 8.2, 8.3]
laravel: [10]
stability: [prefer-dist]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
name: STD-PULL - ${{ matrix.os }} - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}
env:
extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr

steps:
- name: Checkout code
uses: actions/checkout@v3


- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: ${{ runner.os }}-${{ env.extensionKey }}

- name: Cache extensions
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl, iconv, fileinfo
extensions: ${{ env.extensions }}
tools: phpunit:latest
ini-values: memory_limit=512M
coverage: none
Expand All @@ -41,8 +59,8 @@ jobs:
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-
key: ${{ runner.os }}-STDPULL-PHP-${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-STDPULL-PHP-${{ matrix.php }}-L${{ matrix.laravel }}-composer-

- name: Add token
run: |
Expand All @@ -53,11 +71,7 @@ jobs:
run: composer require "laravel/framework:${{ matrix.laravel }}.*" --no-interaction --no-update

- name: Update dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer update --${{ matrix.stability }} --no-interaction

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

- name: Run Unit Tests
run: php ./vendor/bin/paratest --no-coverage --processes=4
30 changes: 24 additions & 6 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,39 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.1, 8.2]
php: [8.1, 8.2, 8.3]
laravel: [10]
stability: [prefer-dist]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
name: STD-PUSH - ${{ matrix.os }} - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}
env:
extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr

steps:
- name: Checkout code
uses: actions/checkout@v3


- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: ${{ env.extensionKey }}

- name: Cache extensions
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ runner.os }}-${{ steps.extcache.outputs.key }}
restore-keys: ${{ runner.os }}-${{ steps.extcache.outputs.key }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl, iconv, fileinfo
extensions: ${{ env.extensions }}
tools: phpunit:latest
ini-values: memory_limit=512M
coverage: none
Expand All @@ -41,8 +59,8 @@ jobs:
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-PHP${{ matrix.php }}-Laravel${{ matrix.laravel }}-composer-
key: ${{ runner.os }}-STDPUSH-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-STDPUSH-PHP${{ matrix.php }}-L${{ matrix.laravel }}-composer-

- name: Add token
run: |
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to `laravel-livewire-tables` will be documented in this file

## UNRELEASED
### New Features
- Add capability to use as a Full Page Component by @amshehzad and @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1580
- Add DateColumn by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1589
- Add ColorColumn by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1590

### Tweaks
- Internal - modify GitHub workflows to improve caching, but use unique caches per workflow matrix
- Internal - remove superfluous PHPStan ignoreErrors
- Internal - update Test Suite to also test at PHP 8.3
- Internal - tidying Classes & Traits by @lrljoe
- Docs - Update Anonymous Column documents to reference ability to use strings as well as views

## [v3.1.4] - 2023-12-04
### New Features
- Add capability to hide Column Label by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1512
Expand All @@ -13,6 +26,10 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
- Fixed extraneous space in config.php by @viliusvsx in in https://github.com/rappasoft/laravel-livewire-tables/pull/1577
- Changed table default vertical overflow to auto by @dmyers in https://github.com/rappasoft/laravel-livewire-tables/pull/1573
- Fix footer rendering issue with extra td displayed depending on bulk action statuses
- Create new WithCustomisations Trait
- Move render data provision into Traits -> WithColumns, WithCustomisations, WithData
- Add default pint.json with ignore for WithAllTraits
- Updated tests & test cases to cater for No Primary Key more efficiently

### Tweaks
- Create additional Exception Classes (NoColumnsException, NoSearchableColumnsException, NoSortableColumnsException)
Expand Down Expand Up @@ -1096,4 +1113,4 @@ Ground Up Rebuild
[0.1.4]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.3...v0.1.4
[0.1.3]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.2...v0.1.3
[0.1.2]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.0...v0.1.1
[0.1.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.0...v0.1.1
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
}
],
"require": {
"php": "^8.1|^8.2",
"php": "^8.1|^8.2|^8.3",
"blade-ui-kit/blade-heroicons": "^2.1",
"illuminate/contracts": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0",
"livewire/livewire": "^3.0|dev-main"
},
"require-dev": {
"ext-sqlite3": "*",
"brianium/paratest": "^5.0|^6.0|^7.0|^8.0",
"laravel/pint": "^1.10",
"monolog/monolog": "*",
"nunomaduro/collision": "^6.0|^7.0|^8.0",
"nunomaduro/larastan": "^2.6",
"orchestra/testbench": "^7.0|^8.0|^9.0",
Expand Down
Binary file modified database/database.sqlite
Binary file not shown.
1 change: 1 addition & 0 deletions database/migrations/create_test_tables.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CreateTestTables extends Migration
$table->string('name')->index();
$table->string('age')->nullable();
$table->date('last_visit')->nullable();
$table->string('favorite_color')->nullable();
$table->integer('species_id')->unsigned()->nullable();
$table->integer('breed_id')->unsigned()->nullable();
$table->foreign('species_id')->references('id')->on('species');
Expand Down
Binary file modified database/sqlite.database
Binary file not shown.
53 changes: 50 additions & 3 deletions docs/columns/anonymous_columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,59 @@ Though, it doesn't have to be an action column, it could be anything.
By using an anonymous column, you take full control by using your own view component. So if you find the LinkColumn,
ImageColumn, or any of the other columns too restrictive for your needs, then an anonymous column may be what you need.

To make an anonymous column, you create an anonymous function that returns a view into the `label()` method, which will
To make an anonymous column, you create an anonymous function that returns a string or a view into the `label()` method, which will
remove the requirement for a database column. Thus, making it "anonymous". You can also pass variables to the view by
chaining the `with()` method onto the `view()` method that gets returned by the anonymous function into the `label()`.
So you can either pass specific values, or the whole row itself. Lastly, chain the `html()` method to the column so it
So you can either pass specific values, or the whole row itself.

Lastly, you may chain the `html()` method to the column so it
can render your view component as html.

## Example Action Column
## Example Column Using a String
Here is an example of using a label to return the "Full Name" of a User. Note that as we are using a label(), you must add any related fields into the setAdditionalSelects() method in the configure() method.

In this case, we are adding the "forename" and "surname" field from the database to the computed set of selects, then in the label, we are combining those, while capitalising the first letter of each name. There are of course better methods to achieve this use case, however this is just an example of the functionality.

In your `DataTableComponent`:

```php
<?php

namespace App\Livewire;

use App\Models\User;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column;

class UserTable extends DataTableComponent
{
protected $model = User::class;

public function configure(): void
{
$this->setPrimaryKey('id')
->setDefaultSort('id', 'asc')
->setAdditionalSelects(['users.forename as forename', 'users.surname as surname']);
}

public function columns(): array
{
return [
Column::make('id', 'id')
->sortable()
->searchable(),
Column::make('Email', 'email')
->sortable()
->searchable(),
Column::make('Full Name')
->label(fn ($row, Column $column) => ucwords($row->forename ?? '' . ' ' . $row->surname)),

];
}
}
```

## Example Action Column Using Views

Here is an example of an action column using FontAwesome icons for the "view", "edit", and "delete" actions.

Expand Down Expand Up @@ -130,3 +176,4 @@ Or, if you passed the whole record, you could use:
The final result can look something like this:

<img width="1104" alt="users-table-action-column" src="https://github.com/rappasoft/laravel-livewire-tables/assets/9557392/b0432731-c882-45bb-8c53-54a3f485f9a3">

Loading

0 comments on commit 2bfe6df

Please sign in to comment.