https://github.com/joy2fun/filament-ext
https://github.com/joy2fun/filament-ext
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/joy2fun/filament-ext
- Owner: joy2fun
- License: mit
- Created: 2024-07-26T05:29:01.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2026-01-12T13:10:11.000Z (5 months ago)
- Last Synced: 2026-01-12T19:57:44.539Z (5 months ago)
- Language: PHP
- Size: 74.2 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
## sms code
use trait in livewire component:
```php
use Joy2fun\FilamentExt\Forms\Concerns\InteractsWithSmsCode;
// setup a sender
public function getSmsCodeSender(): Closure
{
return function(string $mobile, string $code) {
// send sms
Log::debug("sms sent", func_get_args());
};
}
```
use input in filament form
```php
[
TextInput::make('phone')
->regex('/^\d{10,15}$/')
->rules(['required'])
->label('手机号'),
SmsCodeInput::make('code')
->mobileField('phone')
->dehydrated(false)
->regex('/^\d{4,6}$/')
->label('验证码')
->rules([
'required',
fn(Get $get): \Closure => function (string $attribute, $value, \Closure $fail) use ($get) {
SmsCode::attempt($get('phone') ?? '', $value) or $fail('验证码无效');
},
]),
]
```
## popup captcha
```php
use Joy2fun\FilamentExt\Forms\Concerns\InteractsWithCaptcha;
```
include blade view
```blade
@include('filament-ext::components.captcha')
```
popup captcha modal and halt
```php
if (!$this->captchaShouldPass()) {
$this->popupCaptcha();
return ;
}
```
captcha free minutes if passed validation
```php
config([
'filament-ext.captcha_free_minutes' => 10,
])
```
## modal alert message
include blade view
```blade
@include('filament-ext::components.alert')
```
from server:
```php
$this->dispatch('alert', message: 'something wrong');
```
from alpine js:
```js
$dispatch('alert', {message: 'something wrong'})
```