oriondevelops / filament-greeter
一个用于问候用户的Filament插件。
v0.2.0
2024-09-26 18:43 UTC
Requires
- php: ^8.1
- filament/filament: ^3.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.1
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
README
这个Filament插件是nova-greeter的兄弟插件,它扩展了默认的账户小部件,让您
- 为自己和用户设置花哨的头衔
- 添加自定义操作
- 更改欢迎信息
- 更改头像大小
- 禁用头像
安装
您可以通过composer安装此包
composer require oriondevelops/filament-greeter
使用方法
您需要将插件与您首选的Filament面板提供商注册。这可以在您的PanelProvider中完成,例如AdminPanelProvider。
<?php namespace App\Providers\Filament; use Filament\Panel; use Filament\PanelProvider; use Filament\Actions\Action; use Orion\FilamentBackup\BackupPlugin; use Orion\FilamentGreeter\GreeterPlugin; use Orion\FilamentFeedback\FeedbackPlugin; class AdminPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel // ... ->plugins([ BackupPlugin::make() ->queue('monitors'), // ... GreeterPlugin::make() ->message('Welcome,') ->name('Daenerys Targaryen') ->title('The First of Her Name, the Unburnt, Queen of Meereen, Queen of the Andals and the Rhoynar and the First Men, Khalisee of the Great Grass Sea, Breaker of Chains and Mother of Dragons') ->avatar(size: 'w-16 h-16', url: 'https://avatarfiles.alphacoders.com/236/236674.jpg') ->action( Action::make('action') ->label('Buy more unsullied') ->icon('heroicon-o-shopping-cart') ->url('https://buyunsulliedonline.com') ) ->sort(-1) ->columnSpan('full'), // ... FeedbackPlugin::make() ->sendResponsesTo(email: 'oriondevelops@gmail.com'), ]) } }
消息
->message(text: 'Welcome')
为了动态确定欢迎信息,您可以使用闭包
->message(text: fn() => auth()->user()->hasRole('Super Administrator') ? __('Welcome my lord') : __('Welcome'))
时间敏感问候
->timeSensitive(morningStart: 6, afternoonStart: 12, eveningStart: 17, nightStart: 22)
根据当前时间,问候信息将更改为“早上好”、“下午好”、“晚上好”或“晚安”。您可以选择省略小时参数以使用默认时间。
标题
->title(text: 'Administrator', enabled: true)
要基于用户更改标题,您可以使用闭包
->title(text: fn() => auth()->user()->title)
头像
->avatar(size: 'lg', enabled: true),
操作
->action( Action::make('action') ->label('Buy more unsullied') ->icon('heroicon-o-shopping-cart') ->url('https://buyunsulliedonline.com') )
示例
GreeterPlugin::make()
->message('Welcome')
->name("Rand al'Thor")
->title("Dragon Reborn, Coramoor, Car'a'carn, He Who Comes With the Dawn, Shadowkiller, King of Illian, Lord of the Morning")
->avatar(size: 'w-16 h-16')
->columnSpan('full')
->action(
Action::make('action')
->label('Reborn')
->color('danger')
->icon('heroicon-o-arrow-path')
->action(function () {
Notification::make()
->title('Reborn successfully')
->success()
->send();
})
),
GreeterPlugin::make()
->message('Welcome')
->name("Annatar")
->action(
Action::make('action')
->label('Gift a ring')
->color('warning')
->icon('heroicon-o-gift')
->action(function () {
Notification::make()
->title('Target deceived successfully')
->warning()
->send();
})
),
GreeterPlugin::make()
->avatar(enabled: false),
GreeterPlugin::make()
->timeSensitive()
->name('Ser Arthur Dayne')
->title('Sword of the Morning')
->avatar(size: 'w-16 h-16')
->columnSpan('full')
->action(
Action::make('action')
->label('Protect the Heir')
->icon('heroicon-o-shield-check')
->action(fn () => Notification::make()->title('You failed! You’ve been stabbed in the back.')->danger()->send())
),
贡献
请参阅CONTRIBUTING以获取详细信息。
安全性
请审查安全策略以了解如何报告安全漏洞。
鸣谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。



