feat: initial project setup with Laravel 12 and Filament v4
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use App\Filament\Pages\Auth\Login;
|
||||
use App\Http\Middleware\SetLocale;
|
||||
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\View\PanelsRenderHook;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
use Filament\Navigation\NavigationGroup;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Colors\Color;
|
||||
use Filament\Support\Enums\Width;
|
||||
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\StartSession;
|
||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||
|
||||
class AdminPanelProvider extends PanelProvider
|
||||
{
|
||||
public function boot(): void
|
||||
{
|
||||
\Filament\Support\Facades\FilamentAsset::register([
|
||||
\Filament\Support\Assets\Js::make('audio-speed', asset('js/audio-speed.js')),
|
||||
]);
|
||||
}
|
||||
|
||||
public function panel(Panel $panel): Panel
|
||||
{
|
||||
return $panel
|
||||
->default()
|
||||
->id('admin')
|
||||
->path('admin')
|
||||
->login(Login::class)
|
||||
->colors([
|
||||
'primary' => Color::Blue,
|
||||
'orange' => Color::Orange,
|
||||
])
|
||||
->brandLogo(function () {
|
||||
$key = app()->getLocale() === 'fa' ? 'listlogo_per.png' : 'listlogo_eng.png';
|
||||
$attachment = \Illuminate\Support\Facades\Cache::remember(
|
||||
'brand_logo_' . $key,
|
||||
now()->addHours(24),
|
||||
fn () => \App\Models\OsurgInitial::where('init_parameter', $key)->value('attachment')
|
||||
);
|
||||
return $attachment ? asset('storage/' . $attachment) : null;
|
||||
})
|
||||
->brandLogoHeight('1.75rem')
|
||||
->brandName('')
|
||||
->favicon(asset('favicon.svg'))
|
||||
->font('Vazirmatn', url: \Illuminate\Support\Facades\Vite::asset('resources/css/vazirmatn.css'), provider: \Filament\FontProviders\LocalFontProvider::class)
|
||||
->renderHook(
|
||||
PanelsRenderHook::TOPBAR_LOGO_AFTER,
|
||||
fn (): string => view('components.persian-datetime')->render(),
|
||||
)
|
||||
->renderHook(
|
||||
PanelsRenderHook::GLOBAL_SEARCH_BEFORE,
|
||||
fn (): string => \Blade::render('@livewire(\'settings-dropdown\')'),
|
||||
)
|
||||
->renderHook(
|
||||
PanelsRenderHook::BODY_END,
|
||||
fn (): string => <<<'HTML'
|
||||
<script>
|
||||
(function () {
|
||||
var speeds = [0.5, 1, 1.5, 2];
|
||||
document.addEventListener('click', function (e) {
|
||||
var btn = e.target.closest('.filepond--media-player-button-playbackrate');
|
||||
if (!btn) return;
|
||||
var item = btn.closest('.filepond--item, .filepond--root');
|
||||
if (!item) return;
|
||||
var media = item.querySelector('audio, video');
|
||||
if (!media) return;
|
||||
var current = media.playbackRate || 1;
|
||||
var idx = speeds.indexOf(current);
|
||||
var next = speeds[(idx + 1) % speeds.length];
|
||||
media.playbackRate = next;
|
||||
btn.textContent = next + 'x';
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
HTML,
|
||||
)
|
||||
->userMenuItems([
|
||||
Action::make('switch_language')
|
||||
->label(fn () => app()->getLocale() === 'fa' ? 'English' : 'فارسی')
|
||||
->icon('heroicon-o-language')
|
||||
->url(fn () => route('locale.switch', app()->getLocale() === 'fa' ? 'en' : 'fa')),
|
||||
])
|
||||
->navigationGroups([
|
||||
NavigationGroup::make('بیماران و ویزیت'),
|
||||
NavigationGroup::make('بیماریها و روشهای درمان'),
|
||||
NavigationGroup::make('اطلاعات کلینیک'),
|
||||
NavigationGroup::make('تنظیمات'),
|
||||
])
|
||||
->sidebarFullyCollapsibleOnDesktop()
|
||||
->maxContentWidth(Width::Full)
|
||||
->viteTheme('resources/css/filament/admin/theme.css')
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
|
||||
->plugins([
|
||||
FilamentShieldPlugin::make(),
|
||||
])
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages')
|
||||
->pages([])
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets')
|
||||
->widgets([])
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
StartSession::class,
|
||||
AuthenticateSession::class,
|
||||
ShareErrorsFromSession::class,
|
||||
VerifyCsrfToken::class,
|
||||
SubstituteBindings::class,
|
||||
DisableBladeIconComponents::class,
|
||||
DispatchServingFilamentEvent::class,
|
||||
SetLocale::class,
|
||||
])
|
||||
->authMiddleware([
|
||||
Authenticate::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user