Skip to content

Commit a19df25

Browse files
committed
feat: 添加多个新文件,包含表单组件和状态管理逻辑
1 parent 0925305 commit a19df25

Some content is hidden

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

52 files changed

+2523
-983
lines changed

.github/copilot-instructions.md

Lines changed: 507 additions & 0 deletions
Large diffs are not rendered by default.

.junie/mcp/mcp.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"mcpServers": {
3+
"laravel-boost": {
4+
"command": "/Users/ice/Library/Application Support/Herd/bin/php84",
5+
"args": [
6+
"/Users/ice/code/php/laravel/laravel-skeleton/artisan",
7+
"boost:mcp"
8+
]
9+
}
10+
}
11+
}

app/Filament/Pages/Auth/Login.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace App\Filament\Pages\Auth;
4+
5+
use Filament\Auth\Pages\Login as BaseLogin;
6+
use Filament\Forms\Components\TextInput;
7+
use Filament\Schemas\Components\Component;
8+
use Filament\Schemas\Schema;
9+
use Illuminate\Validation\ValidationException;
10+
11+
class Login extends BaseLogin
12+
{
13+
// 使用 username 替换默认的 email 输入框
14+
public function form(Schema $schema): Schema
15+
{
16+
return $schema
17+
->components([
18+
$this->getUsernameFormComponent(),
19+
$this->getPasswordFormComponent(),
20+
$this->getRememberFormComponent(),
21+
]);
22+
}
23+
24+
protected function getUsernameFormComponent(): Component
25+
{
26+
return TextInput::make('username')
27+
->label(__('Username'))
28+
->required()
29+
->extraInputAttributes(['tabindex' => 2]);
30+
}
31+
32+
protected function getCredentialsFromFormData(array $data): array
33+
{
34+
return [
35+
'username' => $data['username'],
36+
'password' => $data['password'],
37+
];
38+
}
39+
40+
// 登录失败时,将错误显示在 username 字段
41+
protected function throwFailureValidationException(): never
42+
{
43+
throw ValidationException::withMessages([
44+
'data.username' => __('auth.failed'),
45+
]);
46+
}
47+
}

app/Providers/FilamentServiceProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Providers;
44

5+
use App\Filament\Pages\Auth\Login;
56
use Filament\Http\Middleware\Authenticate;
67
use Filament\Http\Middleware\DisableBladeIconComponents;
78
use Filament\Http\Middleware\DispatchServingFilamentEvent;
@@ -10,7 +11,6 @@
1011
use Filament\Panel;
1112
use Filament\PanelProvider;
1213
use Filament\Support\Colors\Color;
13-
use Filament\Support\Enums\MaxWidth;
1414
use Filament\Widgets\AccountWidget;
1515
use Filament\Widgets\FilamentInfoWidget;
1616
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
@@ -29,7 +29,7 @@ public function panel(Panel $panel): Panel
2929
->default()
3030
->id('filament')
3131
->path('filament')
32-
->login()
32+
->login(Login::class)
3333
->colors([
3434
'primary' => Color::Amber,
3535
])
@@ -57,7 +57,7 @@ public function panel(Panel $panel): Panel
5757
->authMiddleware([
5858
Authenticate::class,
5959
])
60-
->maxContentWidth(MaxWidth::Full)
60+
->maxContentWidth('full')
6161
->spa()
6262
->navigationItems([
6363
NavigationItem::make('Telescope')

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"php": "^8.4",
1313
"cerbero/laravel-enum": "^2.1",
1414
"dedoc/scramble": "^v0.12.5",
15-
"filament/filament": "^3.2",
16-
"filament/spatie-laravel-media-library-plugin": "^3.3",
15+
"filament/filament": "^4.0",
16+
"filament/spatie-laravel-media-library-plugin": "^4.0",
1717
"laravel/framework": "^12.1",
1818
"laravel/horizon": "^5.29",
1919
"laravel/sanctum": "^4.0",
@@ -28,6 +28,7 @@
2828
"brianium/paratest": "^7.8",
2929
"fakerphp/faker": "^1.23",
3030
"larastan/larastan": "^3.1",
31+
"laravel/boost": "^1.0",
3132
"laravel/pail": "^1.1",
3233
"laravel/pint": "^1.13",
3334
"laravel/sail": "^1.26",

0 commit comments

Comments
 (0)