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
12 changes: 7 additions & 5 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ on:

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
name: PHPStan Latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: 8.5
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v3
- name: Install dependencies
env:
XDEBUG_MODE: off
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --ansi

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
run: ./vendor/bin/phpstan analyse -c phpstan.neon.dist --error-format=github
103 changes: 84 additions & 19 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,112 @@ on:

jobs:
test:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.1, 8.2]
laravel: [10.*, 11.*, 12.*]
stability: [prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
php: 8.1
- laravel: 11.*
- php: 8.2
laravel: 11.*
filament: 4.*
testbench: 9.*
php: 8.2
- laravel: 12.*
livewire: ^3.0
pest: ^3.8
pest_plugin_laravel: ^3.1
pest_plugin_livewire: ^3.1
- php: 8.2
laravel: 12.*
filament: 4.*
testbench: 10.*
php: 8.2
livewire: ^3.0
pest: ^3.8
pest_plugin_laravel: ^3.1
pest_plugin_livewire: ^3.1
- php: 8.3
laravel: 12.*
filament: 5.*
testbench: 10.*
livewire: ^4.0
pest: ^4.0
pest_plugin_laravel: ^4.0
pest_plugin_livewire: ^4.0
- php: 8.4
laravel: 12.*
filament: 5.*
testbench: 10.*
livewire: ^4.0
pest: ^4.0
pest_plugin_laravel: ^4.0
pest_plugin_livewire: ^4.0
- php: 8.5
laravel: 12.*
filament: 5.*
testbench: 10.*
livewire: ^4.0
pest: ^4.0
pest_plugin_laravel: ^4.0
pest_plugin_livewire: ^4.0

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

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

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.laravel }}-${{ matrix.filament }}-${{ matrix.testbench }}-${{ matrix.livewire }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.laravel }}-${{ matrix.filament }}-${{ matrix.testbench }}-${{ matrix.livewire }}-
${{ runner.os }}-composer-

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, pcov
coverage: pcov

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

- name: Install dependencies
env:
XDEBUG_MODE: off
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
composer require \
"laravel/framework:${{ matrix.laravel }}" \
"orchestra/testbench:${{ matrix.testbench }}" \
"filament/filament:${{ matrix.filament }}" \
"livewire/livewire:${{ matrix.livewire }}" \
"pestphp/pest:${{ matrix.pest }}" \
"pestphp/pest-plugin-laravel:${{ matrix.pest_plugin_laravel }}" \
"pestphp/pest-plugin-livewire:${{ matrix.pest_plugin_livewire }}" \
--no-interaction --no-update --no-progress --ansi
composer update --prefer-stable --prefer-dist --no-interaction --no-progress --ansi

- name: Execute tests
run: vendor/bin/pest
- name: Prepare coverage directory
run: mkdir -p build/logs

- name: Execute tests with coverage
run: vendor/bin/pest --coverage --coverage-clover build/logs/clover.xml

- name: Sanitize artifact name
run: |
LARAVEL_SAFE=$(echo "${{ matrix.laravel }}" | tr '*' 'x')
FILAMENT_SAFE=$(echo "${{ matrix.filament }}" | tr '*' 'x')
echo "ARTIFACT_NAME=coverage-${{ matrix.php }}-${LARAVEL_SAFE}-${FILAMENT_SAFE}" >> $GITHUB_ENV

- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: build/logs/clover.xml
if-no-files-found: error
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
**/.DS_Store
.idea
.phpunit.result.cache
.phpunit.cache
.vscode
build
composer.lock
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ Add a button to easily clear the cache from your filament admin.

#### Compatibility

| Plugin Version | Filament Version | PHP Version |
|----------------|-----------------|-------------|
| [1.x](https://github.com/cms-multi/filament-clear-cache/tree/1.x) | 2.x | \> 8.0 |
| [2.x](https://github.com/cms-multi/filament-clear-cache/tree/2.x) | 3.x | \> 8.1 |
| Plugin Version | Filament Version | PHP Version |
|-------------------------------------------------------------------|------------------|-------------|
| [1.x](https://github.com/cms-multi/filament-clear-cache/tree/1.x) | 2.x | \> 8.0 |
| [2.x](https://github.com/cms-multi/filament-clear-cache/tree/2.x) | 3.x | \> 8.1 |
| [3.x](https://github.com/cms-multi/filament-clear-cache/tree/3.x) | 4.x + 5.x | \> 8.2 |


## Installation

Expand Down Expand Up @@ -67,7 +69,7 @@ To increment the button count call Livewire event `clearCacheIncrement`.
// Livewire v2
$this->emit('clearCacheIncrement');

// Livewire v3
// Livewire v3+
$this->dispatch('clearCacheIncrement')->to(\CmsMulti\FilamentClearCache\Http\Livewire\ClearCache::class);
```

Expand Down
46 changes: 23 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "cms-multi/filament-clear-cache",
"description": "Clear your cache easily from within filament",
"keywords": [
"filament",
"laravel",
"filament-clear-cache"
"filament-clear-cache",
"filamentphp",
"laravel"
],
"homepage": "https://github.com/cms-multi/filament-clear-cache",
"support": {
Expand All @@ -20,25 +20,23 @@
}
],
"require": {
"php": "^8.1",
"filament/filament": "^3.0",
"filament/notifications": "^3.0",
"spatie/laravel-package-tools": "^1.15.0",
"illuminate/contracts": "^10.0|^11.0|^12.0"
"php": "^8.2",
"filament/filament": "^4.0 || ^5.0",
"filament/notifications": "^4.0 || ^5.0",
"spatie/laravel-package-tools": "^1.15",
"illuminate/contracts": "^11.0 || ^12.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.9",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"pestphp/pest-plugin-livewire": "^2.1",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"spatie/laravel-ray": "^1.26"
"larastan/larastan": "^3.0",
"orchestra/testbench": "^10.0",
"pestphp/pest": "^4.0",
"pestphp/pest-plugin-laravel": "^4.0",
"pestphp/pest-plugin-livewire": "^4.0",
"phpstan/phpstan": "^2.1",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-phpunit": "^2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -52,14 +50,16 @@
},
"scripts": {
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint"
"analyse": "phpstan analyse",
"lint": "pint",
"test": "pest",
"test:coverage": "pest --coverage",
"test:lint": "pint --test"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": true,
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
}
Expand Down
Empty file removed phpstan-baseline.neon
Empty file.
5 changes: 1 addition & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
includes:
- phpstan-baseline.neon

parameters:
level: 4
paths:
- src
- config
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
checkMissingIterableValueType: false

64 changes: 36 additions & 28 deletions resources/views/livewire/clear-cache-button.blade.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
<button
x-data="{{ json_encode(['visible' => $visible]) }}"
x-show="visible"
wire:click="clear"
wire:loading.attr="disabled"
wire:key="clear-cache-button"
type="button"
class="flex flex-shrink-0 w-10 h-10 rounded-full bg-gray-200 items-center justify-center relative dark:bg-gray-900"
x-tooltip.raw="{{ __('filament-clear-cache::general.clear_cache') }}"
>
@svg('heroicon-s-trash', 'w-5 h-5', ['wire:loading.remove.delay'])
<div class="relative">
<x-filament::icon-button
icon="heroicon-o-trash"
color="gray"
class="flex-shrink-0 w-10 h-10 rounded-full"
tooltip="Clear Cache"
wire:click="clear"
wire:loading.attr="disabled"
x-data="{ visible: true }"
x-show="visible"
wire:key="clear-cache-button"
>
<x-slot name="icon">
<svg wire:loading.remove.delay class="w-5 h-5" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd"
d="M16.5 4.478v.227a48.816 48.816 0 0 1 3.878.512.75.75 0 1 1-.256 1.478l-.209-.035-1.005 13.07a3 3 0 0 1-2.991 2.77H8.084a3 3 0 0 1-2.991-2.77L4.087 6.66l-.209.035a.75.75 0 0 1-.256-1.478A48.567 48.567 0 0 1 7.5 4.705v-.227c0-1.564 1.213-2.9 2.816-2.951a52.662 52.662 0 0 1 3.369 0c1.603.051 2.815 1.387 2.815 2.951Zm-6.136-1.452a51.196 51.196 0 0 1 3.273 0C14.39 3.05 15 3.684 15 4.478v.113a49.488 49.488 0 0 0-6 0v-.113c0-.794.609-1.428 1.364-1.452Zm-.355 5.945a.75.75 0 1 0-1.5.058l.347 9a.75.75 0 1 0 1.499-.058l-.346-9Zm5.48.058a.75.75 0 1 0-1.498-.058l-.347 9a.75.75 0 0 0 1.5.058l.345-9Z"
clip-rule="evenodd" />
</svg>
</x-slot>

<x-filament::loading-indicator x-cloak wire:loading.delay wire:target="clear" class="filament-button-icon w-5 h-5"/>

@if ($cache_count)
<span x-cloak
@class([
"flex items-center justify-center rounded-full bg-primary-500 text-white text-center overflow-hidden absolute text-xs font-bold",
"w-5 h-5" => $cache_count <= 99,
"w-6 h-6" => $cache_count > 99,
])
style="top:-0.4rem;right:-0.4rem;line-height:1;letter-spacing:-1px;font-size:10px;font-weight:600;word-spacing:-1px;"
>
@if($cache_count > 99)
<span>99<span style="vertical-align:text-top;">+</span></span>
@else
{{ $cache_count }}
@endif
<svg wire:loading.delay wire:target="clear"
class="fi-icon fi-loading-indicator fi-size-md filament-button-icon w-5 h-5"
fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd"
d="M12 19C15.866 19 19 15.866 19 12C19 8.13401 15.866 5 12 5C8.13401 5 5 8.13401 5 12C5 15.866 8.13401 19 12 19ZM12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"
fill-rule="evenodd" fill="currentColor" opacity="0.2"/>
<path d="M2 12C2 6.47715 6.47715 2 12 2V5C8.13401 5 5 8.13401 5 12H2Z"
fill="currentColor"/>
</svg>
</x-filament::icon-button>
@if($cache_count > 0)
<span
wire:loading.remove
class="absolute -top-1 -right-1 bg-danger-500 text-white text-xs font-bold w-5 h-5 flex items-center justify-center rounded-full shadow">
{{ $cache_count }}
</span>
@endif
</button>
</div>
Loading