Skip to content

Commit f48a8a6

Browse files
committed
Revert "refactor: remove Filament Shield plugin"
This reverts commit 1a9b6b0.
1 parent 0e9fe7c commit f48a8a6

5 files changed

Lines changed: 19 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This package contains all common non-opinionated code that is used in our Eclips
1414
## Requirements
1515
- PHP 8.2
1616
- Filament 4
17+
- Filament Shield plugin (to manage permissions)
1718
- Laravel Scout
1819

1920
See [composer.json](composer.json) for details.

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040
},
4141
"require": {
4242
"php": "^8.2",
43-
"ext-intl": "*",
43+
"bezhansalleh/filament-shield": "^4.0",
4444
"datalinx/php-utils": "^2.5",
45+
"ext-intl": "*",
4546
"filament/filament": "^4.0",
4647
"filament/spatie-laravel-settings-plugin": "^4.0",
4748
"laravel/scout": "^10.14",
@@ -71,6 +72,8 @@
7172
"@php vendor/bin/testbench serve --ansi"
7273
],
7374
"setup": [
75+
"@php vendor/bin/testbench vendor:publish --provider='Spatie\\Permission\\PermissionServiceProvider'",
76+
"@php vendor/bin/testbench vendor:publish --tag='filament-shield-config'",
7477
"@php vendor/bin/testbench package:sync-skeleton"
7578
]
7679
},

tests/Pest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717

1818
uses(TestCase::class)
1919
->use(RefreshDatabase::class)
20+
->beforeEach(function () {
21+
// Seed roles and permissions with Filament Shield plugin
22+
Artisan::call('shield:generate', [
23+
'--all' => null,
24+
'--panel' => 'admin',
25+
'--option' => 'permissions',
26+
]);
27+
})
2028
->in(__DIR__);
2129

2230
/*

workbench/app/Models/User.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
use Illuminate\Database\Eloquent\Factories\HasFactory;
88
use Illuminate\Foundation\Auth\User as Authenticatable;
99
use Illuminate\Notifications\Notifiable;
10+
use Spatie\Permission\Traits\HasRoles;
1011
use Workbench\Database\Factories\UserFactory;
1112

1213
class User extends Authenticatable implements FilamentUser
1314
{
14-
use HasFactory, Notifiable;
15+
use HasFactory, HasRoles, Notifiable;
1516

1617
/**
1718
* The attributes that are mass assignable.

workbench/app/Providers/AdminPanelProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Workbench\App\Providers;
44

5+
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
56
use Filament\Http\Middleware\Authenticate;
67
use Filament\Http\Middleware\DisableBladeIconComponents;
78
use Filament\Http\Middleware\DispatchServingFilamentEvent;
@@ -41,6 +42,9 @@ public function panel(Panel $panel): Panel
4142
->authMiddleware([
4243
Authenticate::class,
4344
])
45+
->plugins([
46+
FilamentShieldPlugin::make(),
47+
])
4448
->pages([
4549
Dashboard::class,
4650
]);

0 commit comments

Comments
 (0)