Skip to content

Commit

Permalink
Merge pull request #1580 from LowerRockLabs/AddFullPageComponentOptions
Browse files Browse the repository at this point in the history
Add Full Page Component Approach
  • Loading branch information
lrljoe authored Dec 6, 2023
2 parents 7ebbe69 + d462653 commit 69a64c3
Show file tree
Hide file tree
Showing 13 changed files with 316 additions and 33 deletions.
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

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

### 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

## [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 Down
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
61 changes: 61 additions & 0 deletions docs/usage/creating-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Creating Components
weight: 1
---

### In-Line Component
You can create components by using the [command](../start/commands) or copying from one of the [examples](../examples/basic-example).

This is what a bare bones component looks like before your customization:
Expand Down Expand Up @@ -38,3 +39,63 @@ class UsersTable extends DataTableComponent
```

Your component will extend the `Rappasoft\LaravelLivewireTables\DataTableComponent` class and at minimum implement 2 methods called [configure](./configuration) and [columns](../columns/creating-columns).

### Full Page Component
To use a Table as a Full Page Component, there are a few options that you must set in your configure() method.

#### setLayout
To use a Custom Layout (as a Full Page Component), use the setLayout() method, which expects to be passed a string which is the path to the layout.
```php
public function configure(): void
{
$this->setLayout('path-to-layout');
}

```

#### setSlot
To use a Custom Slot (as a Full Page Component), use setSlot() method, which expects to be passed a string which is the name of the slot.
```php
public function configure(): void
{
$this->setSlot('slot-name-here');
}

```

#### setSection
To use a Custom Section (as a Full Page Component), use setSection() method, which expects to be passed a string which is the name of the section.


#### Full Page Component Example
```php
<?php

namespace App\Livewire;

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

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

public function configure(): void
{
$this->setPrimaryKey('id')
->setLayout('path-to-layout')
->setSlot('slot-name-here');
}

public function columns(): array
{
return [
Column::make('ID', 'id')
->sortable(),
Column::make('Name')
->sortable(),
];
}
}
```
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ parameters:
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
- "#Unsafe usage of new static#"
- "#Called 'count' on Laravel collection, but could have been retrieved as a query.#"
- '#Attribute class Rappasoft\\LaravelLivewireTables\\Traits\\Url does not exist.#'
- '#Attribute class Rappasoft\\LaravelLivewireTables\\Traits\\Helpers\\On does not exist.#'
- '#on array\<string, non-empty-array\<int\<0, max\>, mixed\>\> in empty\(\) does not exist.#'
- '#on array<string, non-empty-array<int<0, max>, mixed>> in isset\(\) does not exist#'
- '#on array\<string, non-empty-array\<int\<0, max\>, mixed\>\> in isset\(\) does not exist#'
- '#on non-empty-array<1|string, array<int<0, max>, mixed>> in isset\(\) does not exist.#'
- '#\$callback of method Illuminate\\Support\\Collection<int,string>::filter\(\) expects \(callable\(string, int\): bool\)\|null, Closure\(mixed\): int<0, max> given.#'
- '#Property Illuminate\\Database\\Query\\Builder\:\:\$joins \(array\) on left side of \?\? is not nullable.#'
39 changes: 39 additions & 0 deletions src/Traits/Configuration/CustomisationsConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,43 @@

trait CustomisationsConfiguration
{
/**
* Used to set a Custom Layout if using a Full Page Component approach.
*/
public function setLayout(string $layout): self
{
$this->layout = $layout;

return $this;
}

/**
* Used to set a Custom Slot if using a Full Page Component approach
*/
public function setSlot(string $slot): self
{
$this->slot = $slot;

return $this;
}

/**
* Used to set a Custom Extends Layout if using a Full Page Component approach
*/
public function setExtends(string $extends): self
{
$this->extends = $extends;

return $this;
}

/**
* Used to set a Custom Layout Section if using a Full Page Component approach
*/
public function setSection(string $section): self
{
$this->section = $section;

return $this;
}
}
Loading

0 comments on commit 69a64c3

Please sign in to comment.