Skip to content

Commit 380e05d

Browse files
authored
Filament updates (#86)
* Update bun.lockb * Fix Filament not loading * Install `pxlrbt/filament-environment-indicator` * Make users searchable * Set up environment indicator plugin * Install and configure `stephenjude/filament-debugger ` * Install `laravel/telescope` * Update AppTest.php
1 parent 0e568f0 commit 380e05d

File tree

11 files changed

+965
-392
lines changed

11 files changed

+965
-392
lines changed

app/Filament/Resources/UserResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class UserResource extends Resource
1616

1717
protected static ?string $navigationIcon = 'heroicon-o-users';
1818

19+
protected static ?string $recordTitleAttribute = 'full_name';
20+
1921
public static function form(Form $form): Form
2022
{
2123
return $form

app/Providers/AppServiceProvider.php

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

1111
class AppServiceProvider extends ServiceProvider
1212
{
13+
public function register(): void
14+
{
15+
if ($this->app->environment('local')) {
16+
$this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
17+
$this->app->register(TelescopeServiceProvider::class);
18+
}
19+
}
20+
1321
public function boot(): void
1422
{
1523
JsonResource::withoutWrapping();

app/Providers/Filament/AdminPanelProvider.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@
33
namespace App\Providers\Filament;
44

55
use Althinect\FilamentSpatieRolesPermissions\FilamentSpatieRolesPermissionsPlugin;
6+
use App\Enums\Role;
67
use Filament\Http\Middleware\Authenticate;
78
use Filament\Http\Middleware\DisableBladeIconComponents;
89
use Filament\Http\Middleware\DispatchServingFilamentEvent;
910
use Filament\Pages;
1011
use Filament\Panel;
1112
use Filament\PanelProvider;
13+
use Filament\Support\Colors\Color;
1214
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
1315
use Illuminate\Cookie\Middleware\EncryptCookies;
1416
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
1517
use Illuminate\Routing\Middleware\SubstituteBindings;
1618
use Illuminate\Session\Middleware\AuthenticateSession;
1719
use Illuminate\Session\Middleware\StartSession;
1820
use Illuminate\View\Middleware\ShareErrorsFromSession;
21+
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin;
22+
use Stephenjude\FilamentDebugger\DebuggerPlugin;
1923

2024
class AdminPanelProvider extends PanelProvider
2125
{
@@ -35,7 +39,19 @@ public function panel(Panel $panel): Panel
3539
Pages\Dashboard::class,
3640
])
3741
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
38-
->plugin(FilamentSpatieRolesPermissionsPlugin::make())
42+
->plugins([
43+
FilamentSpatieRolesPermissionsPlugin::make(),
44+
EnvironmentIndicatorPlugin::make()
45+
->visible(fn () => \auth()->user()?->hasRole(Role::SUPER_ADMIN) && \app()->environment() !== 'production')
46+
->color(fn () => match (app()->environment()) {
47+
'production' => Color::Green,
48+
'staging' => Color::Blue,
49+
'local' => Color::Red,
50+
default => Color::Gray,
51+
}),
52+
DebuggerPlugin::make()
53+
->authorize(fn () => \auth()->user()?->hasRole(Role::SUPER_ADMIN) && \app()->environment() !== 'production'),
54+
])
3955
->middleware([
4056
EncryptCookies::class,
4157
AddQueuedCookiesToResponse::class,
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Illuminate\Support\Facades\Gate;
6+
use Laravel\Telescope\IncomingEntry;
7+
use Laravel\Telescope\Telescope;
8+
use Laravel\Telescope\TelescopeApplicationServiceProvider;
9+
10+
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
11+
{
12+
/**
13+
* Register any application services.
14+
*/
15+
public function register(): void
16+
{
17+
// Telescope::night();
18+
19+
$this->hideSensitiveRequestDetails();
20+
21+
$isLocal = $this->app->environment('local');
22+
23+
Telescope::filter(function (IncomingEntry $entry) use ($isLocal) {
24+
return $isLocal ||
25+
$entry->isReportableException() ||
26+
$entry->isFailedRequest() ||
27+
$entry->isFailedJob() ||
28+
$entry->isScheduledTask() ||
29+
$entry->hasMonitoredTag();
30+
});
31+
}
32+
33+
/**
34+
* Prevent sensitive request details from being logged by Telescope.
35+
*/
36+
protected function hideSensitiveRequestDetails(): void
37+
{
38+
if ($this->app->environment('local')) {
39+
return;
40+
}
41+
42+
Telescope::hideRequestParameters(['_token']);
43+
44+
Telescope::hideRequestHeaders([
45+
'cookie',
46+
'x-csrf-token',
47+
'x-xsrf-token',
48+
]);
49+
}
50+
51+
/**
52+
* Register the Telescope gate.
53+
*
54+
* This gate determines who can access Telescope in non-local environments.
55+
*/
56+
protected function gate(): void
57+
{
58+
Gate::define('viewTelescope', function ($user) {
59+
return in_array($user->email, [
60+
//
61+
]);
62+
});
63+
}
64+
}

bootstrap/providers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
return [
44
App\Providers\AppServiceProvider::class,
55
App\Providers\AuthServiceProvider::class,
6-
App\Providers\Filament\AdminPanelServiceProvider::class,
6+
App\Providers\Filament\AdminPanelProvider::class,
77
App\Providers\HorizonServiceProvider::class,
88
];

bun.lockb

-1.98 KB
Binary file not shown.

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@
1313
"laravel/pulse": "^1.2",
1414
"laravel/sanctum": "^4.0",
1515
"laravel/tinker": "^2.9",
16+
"pxlrbt/filament-environment-indicator": "^2.0",
1617
"sentry/sentry-laravel": "^4.7",
1718
"spatie/laravel-permission": "^6.9",
19+
"stephenjude/filament-debugger": "^3.1",
1820
"tightenco/ziggy": "^2.3"
1921
},
2022
"require-dev": {
2123
"barryvdh/laravel-debugbar": "^3.13",
2224
"fakerphp/faker": "^1.23",
2325
"laravel/pint": "^1.17",
26+
"laravel/telescope": "^5.2",
2427
"mockery/mockery": "^1.6",
2528
"nunomaduro/collision": "^8.3",
2629
"pestphp/pest": "^3.0",
@@ -97,7 +100,9 @@
97100
},
98101
"extra": {
99102
"laravel": {
100-
"dont-discover": []
103+
"dont-discover": [
104+
"laravel/telescope"
105+
]
101106
}
102107
},
103108
"config": {

0 commit comments

Comments
 (0)