Skip to content

Upgrade filament #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 26, 2023
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
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ APP_KEY=
APP_DEBUG=true
APP_URL=http://laravel.cm.test
FILAMENT_PATH=cp
FRONTEND_APP_URL=http://localhost:4200

LOG_CHANNEL=stack
LOG_LEVEL=debug
Expand Down Expand Up @@ -79,7 +78,7 @@ TELEGRAM_BOT_TOKEN=
TELEGRAM_CHANNEL=

MEDIA_DISK=media
FORMS_FILESYSTEM_DRIVER=${MEDIA_DISK}
FILAMENT_FILESYSTEM_DISK=${MEDIA_DISK}

SENTRY_LARAVEL_DSN=
SENTRY_TRACES_SAMPLE_RATE=
Expand Down
19 changes: 1 addition & 18 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,16 @@ yarn-error.log
yarn.lock
package-lock.json

# Composer
#
/vendor
composer.phar

# IntelliJ/PhpStorm
#
/.idea

# Visual Studio Code
#
/.vscode

# Netbeans
#
/nbproject
.project

/.vagrant

# Laravel Exclude
#
sitemap.xml
.phpunit.result.cache
.php-cs-fixer.cache
/public/build
/public/hot
/public/storage
/public/media
Expand All @@ -39,8 +24,6 @@ sitemap.xml
/storage/framework/cache
.env
.env.backup
Homestead.json
Homestead.yaml
.phpstorm.meta.php
_ide_helper.php
_ide_helper_models.php
Expand Down
2 changes: 1 addition & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function isLoggedInUser(): bool
return $this->id === Auth::id();
}

public function canAccessFilament(): bool
public function canAccessPanel(\Filament\Panel $panel): bool
{
return str_ends_with($this->email, '@laravel.cm') || $this->isModerator() || $this->isAdmin();
}
Expand Down
16 changes: 0 additions & 16 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use App\View\Composers\TopContributorsComposer;
use App\View\Composers\TopMembersComposer;
use Carbon\Carbon;
use Filament\Facades\Filament;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
Expand All @@ -42,7 +41,6 @@ public function boot(): void
$this->bootMacros();
$this->bootViewsComposer();
$this->bootEloquentMorphs();
$this->bootFilament();

ReplyResource::withoutWrapping();
}
Expand Down Expand Up @@ -85,18 +83,4 @@ public function bootEloquentMorphs(): void
'user' => User::class,
]);
}

public function bootFilament(): void
{
Filament::serving(function (): void {
Filament::registerTheme(
mix('css/filament.css'),
);
});

Filament::registerRenderHook(
'body.start',
fn (): string => Blade::render('@livewire(\'livewire-ui-modal\')'),
);
}
}
70 changes: 70 additions & 0 deletions app/Providers/Filament/AdminPanelProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

declare(strict_types=1);

namespace App\Providers\Filament;

use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Pages;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use Filament\Widgets;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\Support\Facades\Blade;
use Illuminate\View\Middleware\ShareErrorsFromSession;

final class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path(env('FILAMENT_PATH', 'admin'))
->domain(env('FILAMENT_DOMAIN'))
->login()
->colors([
'primary' => Color::Green,
])
->darkMode(false)
->favicon(asset('images/favicons/favicon-32x32.png'))
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->pages([
Pages\Dashboard::class,
])
->widgets([
Widgets\AccountWidget::class,
Widgets\FilamentInfoWidget::class,
])
->renderHook(
'body.start',
fn (): string => Blade::render('@livewire(\'livewire-ui-modal\')'),
)
->databaseNotifications()
->databaseNotificationsPolling('3600s')
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->authMiddleware([
Authenticate::class,
]);
}
}
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"archtechx/laravel-seo": "^0.5.1",
"arrilot/laravel-widgets": "^3.13.2",
"bensampo/laravel-enum": "^6.3.3",
"blade-ui-kit/blade-heroicons": "^1.4",
"blade-ui-kit/blade-heroicons": "^2.0",
"blade-ui-kit/blade-ui-kit": "^0.3.4",
"cyrildewit/eloquent-viewable": "^6.1",
"doctrine/dbal": "^3.6.4",
"filament/filament": "^2.0",
"filament/notifications": "^2.17.49",
"filament/filament": "^3.0",
"filament/notifications": "^3.0",
"francescomalatesta/laravel-feature": "^3.0",
"graham-campbell/markdown": "^14.0",
"guzzlehttp/guzzle": "^7.7.0",
Expand All @@ -31,6 +31,7 @@
"laravel/tinker": "^2.8.1",
"livewire/livewire": "^2.12.3",
"lorisleiva/laravel-actions": "^2.6",
"mckenziearts/blade-untitledui-icons": "^1.2",
"nnjeim/world": "^1.1.27",
"notchpay/notchpay-php": "^1.3",
"qcod/laravel-gamify": "^1.0.7",
Expand All @@ -56,6 +57,7 @@
"barryvdh/laravel-ide-helper": "^2.13",
"brianium/paratest": "^6.10",
"fakerphp/faker": "^1.23.0",
"filament/upgrade": "^3.0",
"laravel/pint": "^1.10.3",
"laravel/sail": "^1.23.0",
"mockery/mockery": "^1.6.2",
Expand Down
Loading