Skip to content

Commit e3eb352

Browse files
authored
Upgrade filament (#132)
* Upgrate to filament v3 * migrate from laravel mix to vite * Add files to gitignore * Fix code styling --------- Co-authored-by: mckenziearts <[email protected]>
1 parent ff3d3a4 commit e3eb352

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1556
-1485
lines changed

.env.example

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ APP_KEY=
44
APP_DEBUG=true
55
APP_URL=http://laravel.cm.test
66
FILAMENT_PATH=cp
7-
FRONTEND_APP_URL=http://localhost:4200
87

98
LOG_CHANNEL=stack
109
LOG_LEVEL=debug
@@ -79,7 +78,7 @@ TELEGRAM_BOT_TOKEN=
7978
TELEGRAM_CHANNEL=
8079

8180
MEDIA_DISK=media
82-
FORMS_FILESYSTEM_DRIVER=${MEDIA_DISK}
81+
FILAMENT_FILESYSTEM_DISK=${MEDIA_DISK}
8382

8483
SENTRY_LARAVEL_DSN=
8584
SENTRY_TRACES_SAMPLE_RATE=

.gitignore

+1-18
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,16 @@ yarn-error.log
66
yarn.lock
77
package-lock.json
88

9-
# Composer
10-
#
119
/vendor
1210
composer.phar
1311

14-
# IntelliJ/PhpStorm
15-
#
1612
/.idea
17-
18-
# Visual Studio Code
19-
#
2013
/.vscode
2114

22-
# Netbeans
23-
#
24-
/nbproject
25-
.project
26-
27-
/.vagrant
28-
2915
# Laravel Exclude
3016
#
31-
sitemap.xml
3217
.phpunit.result.cache
33-
.php-cs-fixer.cache
18+
/public/build
3419
/public/hot
3520
/public/storage
3621
/public/media
@@ -39,8 +24,6 @@ sitemap.xml
3924
/storage/framework/cache
4025
.env
4126
.env.backup
42-
Homestead.json
43-
Homestead.yaml
4427
.phpstorm.meta.php
4528
_ide_helper.php
4629
_ide_helper_models.php

app/Models/User.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function isLoggedInUser(): bool
160160
return $this->id === Auth::id();
161161
}
162162

163-
public function canAccessFilament(): bool
163+
public function canAccessPanel(\Filament\Panel $panel): bool
164164
{
165165
return str_ends_with($this->email, '@laravel.cm') || $this->isModerator() || $this->isAdmin();
166166
}

app/Providers/AppServiceProvider.php

-16
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use App\View\Composers\TopContributorsComposer;
1919
use App\View\Composers\TopMembersComposer;
2020
use Carbon\Carbon;
21-
use Filament\Facades\Filament;
2221
use Illuminate\Database\Eloquent\Relations\Relation;
2322
use Illuminate\Support\Facades\Blade;
2423
use Illuminate\Support\Facades\View;
@@ -42,7 +41,6 @@ public function boot(): void
4241
$this->bootMacros();
4342
$this->bootViewsComposer();
4443
$this->bootEloquentMorphs();
45-
$this->bootFilament();
4644

4745
ReplyResource::withoutWrapping();
4846
}
@@ -85,18 +83,4 @@ public function bootEloquentMorphs(): void
8583
'user' => User::class,
8684
]);
8785
}
88-
89-
public function bootFilament(): void
90-
{
91-
Filament::serving(function (): void {
92-
Filament::registerTheme(
93-
mix('css/filament.css'),
94-
);
95-
});
96-
97-
Filament::registerRenderHook(
98-
'body.start',
99-
fn (): string => Blade::render('@livewire(\'livewire-ui-modal\')'),
100-
);
101-
}
10286
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Providers\Filament;
6+
7+
use Filament\Http\Middleware\Authenticate;
8+
use Filament\Http\Middleware\DisableBladeIconComponents;
9+
use Filament\Http\Middleware\DispatchServingFilamentEvent;
10+
use Filament\Pages;
11+
use Filament\Panel;
12+
use Filament\PanelProvider;
13+
use Filament\Support\Colors\Color;
14+
use Filament\Widgets;
15+
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
16+
use Illuminate\Cookie\Middleware\EncryptCookies;
17+
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
18+
use Illuminate\Routing\Middleware\SubstituteBindings;
19+
use Illuminate\Session\Middleware\AuthenticateSession;
20+
use Illuminate\Session\Middleware\StartSession;
21+
use Illuminate\Support\Facades\Blade;
22+
use Illuminate\View\Middleware\ShareErrorsFromSession;
23+
24+
final class AdminPanelProvider extends PanelProvider
25+
{
26+
public function panel(Panel $panel): Panel
27+
{
28+
return $panel
29+
->default()
30+
->id('admin')
31+
->path(env('FILAMENT_PATH', 'admin'))
32+
->domain(env('FILAMENT_DOMAIN'))
33+
->login()
34+
->colors([
35+
'primary' => Color::Green,
36+
])
37+
->darkMode(false)
38+
->favicon(asset('images/favicons/favicon-32x32.png'))
39+
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
40+
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
41+
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
42+
->pages([
43+
Pages\Dashboard::class,
44+
])
45+
->widgets([
46+
Widgets\AccountWidget::class,
47+
Widgets\FilamentInfoWidget::class,
48+
])
49+
->renderHook(
50+
'body.start',
51+
fn (): string => Blade::render('@livewire(\'livewire-ui-modal\')'),
52+
)
53+
->databaseNotifications()
54+
->databaseNotificationsPolling('3600s')
55+
->middleware([
56+
EncryptCookies::class,
57+
AddQueuedCookiesToResponse::class,
58+
StartSession::class,
59+
AuthenticateSession::class,
60+
ShareErrorsFromSession::class,
61+
VerifyCsrfToken::class,
62+
SubstituteBindings::class,
63+
DisableBladeIconComponents::class,
64+
DispatchServingFilamentEvent::class,
65+
])
66+
->authMiddleware([
67+
Authenticate::class,
68+
]);
69+
}
70+
}

composer.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
"archtechx/laravel-seo": "^0.5.1",
1212
"arrilot/laravel-widgets": "^3.13.2",
1313
"bensampo/laravel-enum": "^6.3.3",
14-
"blade-ui-kit/blade-heroicons": "^1.4",
14+
"blade-ui-kit/blade-heroicons": "^2.0",
1515
"blade-ui-kit/blade-ui-kit": "^0.3.4",
1616
"cyrildewit/eloquent-viewable": "^6.1",
1717
"doctrine/dbal": "^3.6.4",
18-
"filament/filament": "^2.0",
19-
"filament/notifications": "^2.17.49",
18+
"filament/filament": "^3.0",
19+
"filament/notifications": "^3.0",
2020
"francescomalatesta/laravel-feature": "^3.0",
2121
"graham-campbell/markdown": "^14.0",
2222
"guzzlehttp/guzzle": "^7.7.0",
@@ -31,6 +31,7 @@
3131
"laravel/tinker": "^2.8.1",
3232
"livewire/livewire": "^2.12.3",
3333
"lorisleiva/laravel-actions": "^2.6",
34+
"mckenziearts/blade-untitledui-icons": "^1.2",
3435
"nnjeim/world": "^1.1.27",
3536
"notchpay/notchpay-php": "^1.3",
3637
"qcod/laravel-gamify": "^1.0.7",
@@ -56,6 +57,7 @@
5657
"barryvdh/laravel-ide-helper": "^2.13",
5758
"brianium/paratest": "^6.10",
5859
"fakerphp/faker": "^1.23.0",
60+
"filament/upgrade": "^3.0",
5961
"laravel/pint": "^1.10.3",
6062
"laravel/sail": "^1.23.0",
6163
"mockery/mockery": "^1.6.2",

0 commit comments

Comments
 (0)